Skip to content
This repository has been archived by the owner on Oct 15, 2021. It is now read-only.

UTF-8 used for Java Properties file. #317

Open
gorandalum opened this issue Jul 2, 2014 · 0 comments
Open

UTF-8 used for Java Properties file. #317

gorandalum opened this issue Jul 2, 2014 · 0 comments
Assignees

Comments

@gorandalum
Copy link

When pulling Java Properties files from Transifex I get the error:
UnicodeDecodeError: 'utf8' codec can't decode byte 0xe4 in position 795: invalid continuation byte

Stacktrace:

Pulling translations for resource project.documents (source: documents/src/main/resources/com/enterprise/project/app/texts_en.properties)
 -> fi: documents/src/main/resources/com/enterprise/project/app/texts_fi.properties
Traceback (most recent call last):
  File "/Users/ghdalum/Dev/transifex-client/tx", line 94, in main
    utils.exec_command(cmd, args[1:], path_to_tx)
  File "/Users/ghdalum/Dev/transifex-client/txclib/utils.py", line 182, in exec_command
    cmd_fn(*args,**kwargs)
  File "/Users/ghdalum/Dev/transifex-client/txclib/commands.py", line 366, in cmd_pull
    mode=options.mode, pseudo=pseudo
  File "/Users/ghdalum/Dev/transifex-client/txclib/project.py", line 499, in pull
    r, charset = self.do_url_request(url, language=remote_lang)
  File "/Users/ghdalum/Dev/transifex-client/txclib/project.py", line 829, in do_url_request
    return make_request(method, hostname, url, username, passwd, data)
  File "/Users/ghdalum/Dev/transifex-client/txclib/utils.py", line 108, in make_request
    data = data.decode(charset)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xe4 in position 795: invalid continuation byte

The .tx/config are:

[main]
host = https://www.transifex.com

[project.documents]
file_filter = project/src/main/resources/com/enterprise/project/app/texts_<lang>.properties
source_file = project/src/main/resources/com/enterprise/project/app/texts_en.properties
source_lang = en
type = PROPERTIES

For not being stuck on this I had to implement a hacky workaround where I edited/hardcoded the determine_charset function in txclib/utils.py to return "ISO-5589-1".

I am sitting on a Mac running OS X Mountain Lion, installed transifex by cloning the git project and used setup.py.

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

No branches or pull requests

2 participants