Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various error with Localizable.strings #8

Open
JulesMoorhouse opened this issue Dec 14, 2021 · 4 comments
Open

Various error with Localizable.strings #8

JulesMoorhouse opened this issue Dec 14, 2021 · 4 comments

Comments

@JulesMoorhouse
Copy link

Hi,

I'm getting the following errors... I'd be grateful for some advice.

I've tried...

translate -p Localizable.strings -d 'de'
translate -p ./Localizable.strings -d 'de'
translate -p ./Localizable.strings -d 'de' -s 'en'

Here's the errors...

translate -p Localizable.strings -d 'de'
Target language: de
[Use google translation]
translating..
Traceback (most recent call last):
  File "/usr/local/bin/translate", line 33, in <module>
    main()
  File "/usr/local/bin/translate", line 29, in main
    mkTranslator().translate_doc(filepath=args.file_path, destination=args.dest_language,sourcelanguage=args.sourcelanguage,channel=args.channel)
  File "/usr/local/lib/python3.9/site-packages/mkTranslation/translator.py", line 165, in translate_doc
    self.write_tx(filepath,newFile,r"=\s*\"(.+?)\"\s*;",'="'+'content'+'";',destination,sourcelanguage,channel)
  File "/usr/local/lib/python3.9/site-packages/mkTranslation/translator.py", line 90, in write_tx
    line = f.readline()
  File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
pip 21.3.1 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)

Thanks...

@trapper-
Copy link

Same errors for me

@trapper-
Copy link

trapper- commented Dec 24, 2021

I made some progress on this error, the Localizable.strings file that Xcode generates is in UTF-16 with BOM format for some strange reason, causes the invalid start byte error. Resaved it as UTF-8 and got past that error, but ran into another :(

translate -p ./Localizable.strings -d es
Target language: es
[Use google translation]
translating..
original:/* No comment provided by engineer. */
skip: /* No comment provided by engineer. */
translated:/* No comment provided by engineer. */
-----
original:"%@ already exists." = "%@ already exists.";
Traceback (most recent call last):
  File "/usr/local/bin/translate", line 33, in <module>
    main()
  File "/usr/local/bin/translate", line 29, in main
    mkTranslator().translate_doc(filepath=args.file_path, destination=args.dest_language,sourcelanguage=args.sourcelanguage,channel=args.channel)
  File "/usr/local/lib/python3.9/site-packages/mkTranslation/translator.py", line 165, in translate_doc
    self.write_tx(filepath,newFile,r"=\s*\"(.+?)\"\s*;",'="'+'content'+'";',destination,sourcelanguage,channel)
  File "/usr/local/lib/python3.9/site-packages/mkTranslation/translator.py", line 101, in write_tx
    txc = self.translate(line[0],des,lan,channel)
  File "/usr/local/lib/python3.9/site-packages/mkTranslation/translator.py", line 73, in translate
    return mkGoogleTranslator().translate(word, dest=destination).text
  File "/usr/local/lib/python3.9/site-packages/mkTranslation/translate_google.py", line 63, in translate
    data = self._translate(text, dest, src)
  File "/usr/local/lib/python3.9/site-packages/mkTranslation/translate_google.py", line 100, in _translate
    token = self.token_acquirer.do(text)
  File "/usr/local/lib/python3.9/site-packages/mkTranslation/network.py", line 175, in do
    self._update()
  File "/usr/local/lib/python3.9/site-packages/mkTranslation/network.py", line 67, in _update
    code = unicode(self.RE_TKK.search(r.text).group(1)).replace('var ', '')
AttributeError: 'NoneType' object has no attribute 'group'

@JulesMoorhouse
Copy link
Author

Ahhh right...

I get the same error 🙁

@mythkiven can you help please ?

Merry Christmas

@Rediska47
Copy link

Rediska47 commented Dec 28, 2022

I am getting the same error. Is there any solution?

translate -p Localizable.strings -d 'ru'
original:"ACCEPT_LARGE_VIDEO_DOWNLOAD"="Download";
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/bin/translate", line 33, in <module>
    main()
  File "/Library/Frameworks/Python.framework/Versions/3.9/bin/translate", line 29, in main
    mkTranslator().translate_doc(filepath=args.file_path, destination=args.dest_language,sourcelanguage=args.sourcelanguage,channel=args.channel)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/mkTranslation/translator.py", line 165, in translate_doc
    self.write_tx(filepath,newFile,r"=\s*\"(.+?)\"\s*;",'="'+'content'+'";',destination,sourcelanguage,channel)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/mkTranslation/translator.py", line 101, in write_tx
    txc = self.translate(line[0],des,lan,channel)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/mkTranslation/translator.py", line 73, in translate
    return mkGoogleTranslator().translate(word, dest=destination).text
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/mkTranslation/translate_google.py", line 63, in translate
    data = self._translate(text, dest, src)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/mkTranslation/translate_google.py", line 100, in _translate
    token = self.token_acquirer.do(text)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/mkTranslation/network.py", line 175, in do
    self._update()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/mkTranslation/network.py", line 67, in _update
    code = unicode(self.RE_TKK.search(r.text).group(1)).replace('var ', '')
AttributeError: 'NoneType' object has no attribute 'group'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants