| 79 | ==== Using `msgfmt` tools ==== |
| 80 | |
| 81 | Although Babel is Python specific and is the tool which is advised to use, |
| 82 | the traditional msgfmt toolset can also be used. |
| 83 | In particular, the following command is quite useful: |
| 84 | {{{ |
| 85 | $ msgfmt --statistics --check trac/locale/pl/LC_MESSAGES/messages.po |
| 86 | 979 translated messages, 85 fuzzy translations, 32 untranslated messages. |
| 87 | }}} |
| 88 | All is well, except for some fuzzy and missing translations ;-) |
| 89 | |
| 90 | {{{ |
| 91 | $ msgfmt --statistics --check trac/locale/zh_CN/LC_MESSAGES/messages.po |
| 92 | trac/locale/zh_CN/LC_MESSAGES/messages.po:2155: a format specification for argument 'unit', as in 'msgstr[0]', doesn't exist in 'msgid' |
| 93 | trac/locale/zh_CN/LC_MESSAGES/messages.po:2162: a format specification for argument 'unit', as in 'msgstr[0]', doesn't exist in 'msgid' |
| 94 | trac/locale/zh_CN/LC_MESSAGES/messages.po:2169: a format specification for argument 'unit', as in 'msgstr[0]', doesn't exist in 'msgid' |
| 95 | msgfmt: found 3 fatal errors |
| 96 | 1058 translated messages. |
| 97 | }}} |
| 98 | Some errors were detected with format specifications. |
| 99 | |
| 100 | This is a useful ''additional'' check, as `python setup.py compile_catalog -l zh_CN` wouldn't have detected that issue. |
| 101 | |
| 102 | ==== The easy way using `make` and l10n targets ==== |
| 103 | |
| 104 | You'll find a Makefile in the toplevel directory of the Trac source. |
| 105 | If you're lucky enough to have the GNU `make` tool, you can benefit from some |
| 106 | automation for these translation tasks. |
| 107 | |
| 108 | {{{ |
| 109 | $ make |
| 110 | ... |
| 111 | ---------------- L10N tasks |
| 112 | |
| 113 | extraction regenerate the messages.pot template file |
| 114 | |
| 115 | update update all the messages.po file(s) |
| 116 | update-xy update the catalog for the xy locale only |
| 117 | |
| 118 | compile compile all the messages.po files |
| 119 | compile-xy compile the catalog for the xy locale only |
| 120 | |
| 121 | check verify all the messages.po files |
| 122 | check-xy verify the catalog for the xy locale only |
| 123 | |
| 124 | stats translation statistics for all catalogs |
| 125 | stats-pot statistics for the messages.pot template file |
| 126 | stats-xy statistics for the xy locale only |
| 127 | |
| 128 | [locale=...] variable for selecting a set of locales |
| 129 | }}} |
| 130 | |
| 131 | Example usage: |
| 132 | {{{ |
| 133 | $ make stats-pot update check compile stats locale='fr de' |
| 134 | translation statistics for messages.pot: |
| 135 | stats-pot: 0 translated messages, 1096 untranslated messages. |
| 136 | python setup.py update_catalog -l fr |
| 137 | running update_catalog |
| 138 | updating catalog 'trac/locale\\fr\\LC_MESSAGES\\messages.po' based on 'trac/locale/messages.pot' |
| 139 | python setup.py update_catalog -l de |
| 140 | running update_catalog |
| 141 | updating catalog 'trac/locale\\de\\LC_MESSAGES\\messages.po' based on 'trac/locale/messages.pot' |
| 142 | checking catalogs for fr de... |
| 143 | check-fr: OK |
| 144 | check-de: OK |
| 145 | All catalogs checked are OK |
| 146 | python setup.py compile_catalog -l fr |
| 147 | running compile_catalog |
| 148 | compiling catalog 'trac/locale\\fr\\LC_MESSAGES\\messages.po' to 'trac/locale\\fr\\LC_MESSAGES\\messages.mo' |
| 149 | python setup.py compile_catalog -l de |
| 150 | running compile_catalog |
| 151 | compiling catalog 'trac/locale\\de\\LC_MESSAGES\\messages.po' to 'trac/locale\\de\\LC_MESSAGES\\messages.mo' |
| 152 | translation statistics for fr de... |
| 153 | stats-fr: 1096 translated messages. |
| 154 | stats-de: 932 translated messages, 164 untranslated messages. |
| 155 | }}} |
| 156 | |