Skip to content

Instantly share code, notes, and snippets.

@cburmeister
Last active August 29, 2015 14:21
Show Gist options
  • Save cburmeister/d922bb26f250c8635fe8 to your computer and use it in GitHub Desktop.
Save cburmeister/d922bb26f250c8635fe8 to your computer and use it in GitHub Desktop.

Syncing catalog with Transifex

Install the latest client:

$ pip install transifex-client==0.11b3

Initialize Transifex configuration directory:

$ tx init --user username --pass password

Map messages catalog with Transifex:

$ tx set \
    --auto-local \
    --resource discogs-i18n.en 'i18n/<lang>/LC_MESSAGES/messages.po' \
    --source-lang en \
    --type PO \
    --source-file i18n/messages.pot \
    --execute

Map js catalog with Transifex:

$ tx set \
    --auto-local \
    --resource discogs-i18n.en 'i18n/<lang>/LC_MESSAGES/messages_js.po' \
    --source-lang en \
    --type PO \
    --source-file i18n/messages_js.pot \
    --execute

Verify catalog was mapped correctly:

$ tx status 
discogs-i18n -> en (1 of 2)
Translation Files:
 - en: i18n/messages.pot (source)
 - bg: i18n/bg/LC_MESSAGES/messages.po
 - cs: i18n/cs/LC_MESSAGES/messages.po
 ...

discogs-i18n -> en_js (2 of 2)
Translation Files:
 - en: i18n/messages_js.pot (source)
 - bg: i18n/bg/LC_MESSAGES/messages_js.po
 - cs: i18n/cs/LC_MESSAGES/messages_js.po
...

Push updated catalog files to Transifex:

$ tx push --source --translations --skip

Pull updated catalog files from Transifex:

$ tx pull --all --skip

Detecting errors in PO files

Install msgfmt to parse po files for syntax errors:

$ msgfmt --check es/LC_MESSAGES/messages.po
    es/LC_MESSAGES/messages.po:3: warning: header field 'PO-Revision-Date' still has the initial default value
    es/LC_MESSAGES/messages.po:3: warning: header field 'Last-Translator' still has the initial default value
    es/LC_MESSAGES/messages.po:3: warning: header field 'Language' missing in header
    es/LC_MESSAGES/messages.po:78: 'msgid' and 'msgstr' entries do not both end with '\n'
    es/LC_MESSAGES/messages.po:2399: 'msgid' and 'msgstr' entries do not both end with '\n'
    es/LC_MESSAGES/messages.po:3088: 'msgid' and 'msgstr' entries do not both end with '\n'
    es/LC_MESSAGES/messages.po:3925: 'msgid' and 'msgstr' entries do not both end with '\n'
    es/LC_MESSAGES/messages.po:10105: 'msgid' and 'msgstr' entries do not both end with '\n'
    msgfmt: found 5 fatal errors

To install on OSX:

$ brew install gettext; brew link gettext --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment