| 1 | HOWTO translate GRASS messages
|
|---|
| 2 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|---|
| 3 |
|
|---|
| 4 | This file contains following sections:
|
|---|
| 5 | 1. Instructions for programmers;
|
|---|
| 6 | 2. A translation workflow overview;
|
|---|
| 7 | 3. A detailed explanation of translation workflow, testing;
|
|---|
| 8 | 4. Some notes and links
|
|---|
| 9 |
|
|---|
| 10 | [ Web page: http://grass.osgeo.org/devel/i18n.php ]
|
|---|
| 11 |
|
|---|
| 12 | Updating the message catalogs currently only works on
|
|---|
| 13 | unix-like systems and requires xgettext.
|
|---|
| 14 |
|
|---|
| 15 | ------------------------------------------------------
|
|---|
| 16 |
|
|---|
| 17 | REQUIRED SOURCE CODE CHANGES (programming required)
|
|---|
| 18 |
|
|---|
| 19 | Generally, to support i18N multiple languages,
|
|---|
| 20 | message strings in GRASS must be modified from
|
|---|
| 21 |
|
|---|
| 22 | fprintf ( ..., "...\n", ...);
|
|---|
| 23 | to either
|
|---|
| 24 | fprintf ( ..., _("...\n"), ...);
|
|---|
| 25 | or (omit \n)
|
|---|
| 26 | G_message ( _("..."), ...);
|
|---|
| 27 |
|
|---|
| 28 | Careful:
|
|---|
| 29 | G_message should be used for messages - information about
|
|---|
| 30 | the process for user while fprintf(stdout...) for data output.
|
|---|
| 31 | G_message output is not expected to be send to pipe or file.
|
|---|
| 32 | fprintf(stdout...) output is usually send to pipe or file.
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 | Three steps:
|
|---|
| 36 | 1) check if fprintf is to be replaced (see above)
|
|---|
| 37 |
|
|---|
| 38 | 2) to add (see example above):
|
|---|
| 39 | the macro _( ) which encapulates the message
|
|---|
| 40 |
|
|---|
| 41 | 3) to be added to file.c header:
|
|---|
| 42 | #include "glocale.h"
|
|---|
| 43 |
|
|---|
| 44 | This line has to be added to each C file which contains
|
|---|
| 45 | user messages, preferably as last #include statement.
|
|---|
| 46 | Only, if missing, also add
|
|---|
| 47 | #include "gis.h"
|
|---|
| 48 |
|
|---|
| 49 | NOTE: Also G_warning() and G_fatal_error() need the message
|
|---|
| 50 | encapsulation with macro _() but no further changes.
|
|---|
| 51 |
|
|---|
| 52 | NOTE2: Also the parameters/flags of each module needs the
|
|---|
| 53 | macro _().
|
|---|
| 54 |
|
|---|
| 55 | NOTE3: Notices to translators can be added by placing
|
|---|
| 56 | a comment line starting with GTC tag just above
|
|---|
| 57 | message to be translated:
|
|---|
| 58 | /* GTC A comma separated keyword list.
|
|---|
| 59 | Should not contain spaces! */
|
|---|
| 60 | keywords = _("first,second,third");
|
|---|
| 61 |
|
|---|
| 62 | NOTE4: Any string containing a number that requires a correct plural form of
|
|---|
| 63 | a noun, has to pass trough ngettext function implemented in GRASS
|
|---|
| 64 | as a n_() macro.
|
|---|
| 65 | n_("Message in English for singular case", "Message in English for
|
|---|
| 66 | plural case", number)
|
|---|
| 67 |
|
|---|
| 68 | Examples of messages with plural forms.
|
|---|
| 69 | Wrong:
|
|---|
| 70 | G_message( _("%d map(s) from mapset <%s> removed"), n, ms);
|
|---|
| 71 | G_message( n == 1 ? _("One file removed") : _("%d files removed"), n);
|
|---|
| 72 | G_warning( _("%d %s without geometry skipped"), n,
|
|---|
| 73 | n == 1 ? "feature" : "features");
|
|---|
| 74 | G_message( _("%d maps selected"), n);
|
|---|
| 75 | G_message( n == 1 ? _("Remove map") : _("Remove maps"));
|
|---|
| 76 |
|
|---|
| 77 | Correct:
|
|---|
| 78 | G_message( n_("%d map from mapset <%s> removed",
|
|---|
| 79 | "%d maps from mapset <%s> removed", n), n, ms);
|
|---|
| 80 | /* Notice double use of number "n" - as an argument for
|
|---|
| 81 | both functions - n_() and G_message() */
|
|---|
| 82 | G_message( n_("One file removed", "%d files removed", n) n);
|
|---|
| 83 | /* Both of forms of singular case "%d file" or "One file" are correct.
|
|---|
| 84 | The choice between them is purely stylistic one. */
|
|---|
| 85 | G_warning( n_("One feature without geometry skipped",
|
|---|
| 86 | "%d features without geometry skipped", n), n);
|
|---|
| 87 | G_message( n_("%d map selected", "%d maps selected", n), n);
|
|---|
| 88 | /* Although in English it is not necessary to provide a separate
|
|---|
| 89 | text if "n" always is >1, in other languages is a difference if "n"
|
|---|
| 90 | is i.e. 2-4, or n==10 etc. */
|
|---|
| 91 | G_message( n_("Remove map", "Remove maps", n));
|
|---|
| 92 | /* Number it self doesn't have to be used in the output text */
|
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 | All these messages strings will be then automatically
|
|---|
| 96 | extracted into the message files.
|
|---|
| 97 |
|
|---|
| 98 | See for example ./vector/v.what.rast/main.c
|
|---|
| 99 |
|
|---|
| 100 | NOTE4: Such lines
|
|---|
| 101 | fprintf (stdout,"\n");
|
|---|
| 102 | do not need a change as no translation is needed.
|
|---|
| 103 |
|
|---|
| 104 | A detailed example of adapting code for use in multiple languages
|
|---|
| 105 | can be found in gettext manual.
|
|---|
| 106 | How to prepare program source:
|
|---|
| 107 | http://www.gnu.org/software/gettext/manual/gettext.html#Sources
|
|---|
| 108 |
|
|---|
| 109 | More advanced tricks like resolving ambiguties and handling of plural forms:
|
|---|
| 110 | http://www.gnu.org/software/gettext/manual/gettext.html#Programmers
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 | TODO: ADD PYTHON code snippets here
|
|---|
| 114 |
|
|---|
| 115 | ------------------------------------------------------
|
|---|
| 116 |
|
|---|
| 117 | GENERAL TRANSLATION PROCEDURE (no programming required)
|
|---|
| 118 |
|
|---|
| 119 | POT files [1] ----> PO files [2] ----> update PO files [3] ----> PO merge + MO files [4]
|
|---|
| 120 | (original (translated (updating of msgs (final binary message file,
|
|---|
| 121 | messages) messages) in Transifex) used by GRASS GIS modules)
|
|---|
| 122 |
|
|---|
| 123 | see also: https://grasswiki.osgeo.org/wiki/GRASS_messages_translation#Get_the_translated_po_files
|
|---|
| 124 |
|
|---|
| 125 | [1] .pot files are auto-generated on grass.osgeo.org and
|
|---|
| 126 | stored in https://grass.osgeo.org/grass77/binary/linux/snapshot/transifex/
|
|---|
| 127 | --> cronjob: /home/neteler/cronjobs/cron_grass77_releasebranch_72_build_bins.sh
|
|---|
| 128 |
|
|---|
| 129 | [2] Transifex job copies daily from [1] to here:
|
|---|
| 130 | https://www.transifex.com/grass-gis/grass77/
|
|---|
| 131 |
|
|---|
| 132 | [3] Translators work in Transifex,
|
|---|
| 133 |
|
|---|
| 134 | [4] Updated po files are taken from Transifex and merged into GRASS GIS source repo
|
|---|
| 135 | (MO files are generated when compiling GRASS GIS)
|
|---|
| 136 | Script: grass-addons/tools/transifex_merge.sh
|
|---|
| 137 |
|
|---|
| 138 | # trim disconnected=obsolete translations
|
|---|
| 139 | POFILE=grassYXZ_LANG.po
|
|---|
| 140 | msgattrib --output-file=$POFILE --no-obsolete $POFILE
|
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 | Semi-automated procedure:
|
|---|
| 144 |
|
|---|
| 145 | 1. In the main GRASS source code directory, run:
|
|---|
| 146 |
|
|---|
| 147 | ./configured --with-nls [...further options...]
|
|---|
| 148 | make
|
|---|
| 149 |
|
|---|
| 150 | 2. In the locale/ directory, run:
|
|---|
| 151 |
|
|---|
| 152 | TODO OLD make pot creates grass.pot (containing original messages)
|
|---|
| 153 |
|
|---|
| 154 | TODO OLD make update-po merges new messages into existing *.po files
|
|---|
| 155 |
|
|---|
| 156 | 3. Now translate the messages in the po/*.po files (using kbabel or
|
|---|
| 157 | other editor). Just open the .po file(s) in your preferred translation
|
|---|
| 158 | software.
|
|---|
| 159 |
|
|---|
| 160 | 4. In the locale/ directory, run:
|
|---|
| 161 |
|
|---|
| 162 | make mo creates the mo files (containing translated messages as
|
|---|
| 163 | binary file)
|
|---|
| 164 |
|
|---|
| 165 | If you have any difficulty with these instructions please ask for help
|
|---|
| 166 | on the GRASS development mailing list <grass-dev lists.osgeo.org>
|
|---|
| 167 | (subscribe at http://lists.osgeo.org/mailman/listinfo/grass-dev). Your
|
|---|
| 168 | willingness, time, and effort translating are valuable. If necessary,
|
|---|
| 169 | all of these steps except for the actual translation can be done by
|
|---|
| 170 | someone else on a different computer.
|
|---|
| 171 |
|
|---|
| 172 | A convenient software package to translate messages is 'kbabel'.
|
|---|
| 173 | It permits to enhance it's message database by loading existing
|
|---|
| 174 | .po files to semi-automate the translation.
|
|---|
| 175 |
|
|---|
| 176 | Note that GRASS must be configured with '--with-nls' and (re)compiled
|
|---|
| 177 | to make use of the translated messages.
|
|---|
| 178 |
|
|---|
| 179 | There is a file for all library messages and another for all
|
|---|
| 180 | module messages (this might be split in future).
|
|---|
| 181 |
|
|---|
| 182 | ------------------------------------------------------
|
|---|
| 183 | DETAILED PROCEDURE :
|
|---|
| 184 |
|
|---|
| 185 | 1. Define/check language settings
|
|---|
| 186 |
|
|---|
| 187 | echo $LANG
|
|---|
| 188 | echo $LANGUAGE
|
|---|
| 189 | echo $LC_ALL
|
|---|
| 190 |
|
|---|
| 191 | Maybe you have to change it (example for Japanese):
|
|---|
| 192 | - for bash shell:
|
|---|
| 193 | export LANG=ja_JP
|
|---|
| 194 | export LANGUAGE=ja_JP
|
|---|
| 195 | export LC_ALL=ja_JP
|
|---|
| 196 |
|
|---|
| 197 | - for (t)csh shell:
|
|---|
| 198 | setenv LANG ja_JP
|
|---|
| 199 | setenv LANGUAGE ja_JP
|
|---|
| 200 | setenv LC_ALL ja_JP
|
|---|
| 201 |
|
|---|
| 202 |
|
|---|
| 203 | 2. CREATE POT FILES
|
|---|
| 204 | run
|
|---|
| 205 | make pot
|
|---|
| 206 |
|
|---|
| 207 | This will create
|
|---|
| 208 | ./templates/grasslibs.pot
|
|---|
| 209 | ./templates/grassmods.pot
|
|---|
| 210 | ./templates/grasswxpy.pot
|
|---|
| 211 |
|
|---|
| 212 |
|
|---|
| 213 | 3. CREATE LANGUAGE FILES
|
|---|
| 214 |
|
|---|
| 215 | Two cases have to be distinguished:
|
|---|
| 216 | a) Messages have not yet been translated to your language.
|
|---|
| 217 | b) Some messages have already been translated to your language,
|
|---|
| 218 | so you want to merge your efforts into the existing translation.
|
|---|
| 219 |
|
|---|
| 220 | 3.a) First CASE: Messages have not yet been translated to your language.
|
|---|
| 221 | No .po file is present for your language in the ./po/ directory.
|
|---|
| 222 |
|
|---|
| 223 | Run:
|
|---|
| 224 | make pot
|
|---|
| 225 | make update-po
|
|---|
| 226 |
|
|---|
| 227 | Move the generated file from the ./template/ directory
|
|---|
| 228 | to the ./po/ directory (for example German language):
|
|---|
| 229 | mv ./template/grasslibs.pot ./po/grasslibs_de.po
|
|---|
| 230 | mv ./template/grassmods.pot ./po/grassmods_de.po
|
|---|
| 231 | mv ./template/grasswxpy.pot ./po/grasswxpy_de.po
|
|---|
| 232 |
|
|---|
| 233 | Get the two characters indicating the language from this
|
|---|
| 234 | code list: http://www.loc.gov/standards/iso639-2/php/English_list.php
|
|---|
| 235 | The code to use is ISO 639-1 (two characters).
|
|---|
| 236 |
|
|---|
| 237 | Then continue with 4. below.
|
|---|
| 238 |
|
|---|
| 239 | 3.b) Second CASE: Some messages have already been translated to
|
|---|
| 240 | your language (files present in ./po/ directory), and
|
|---|
| 241 | you want to continue with translating new and still
|
|---|
| 242 | untranslated messages.
|
|---|
| 243 |
|
|---|
| 244 | First we have to merge new messages into existing .po files
|
|---|
| 245 | (which contain already translated messages) as new messages
|
|---|
| 246 | might have been added into the GRASS system.
|
|---|
| 247 | To do so, run:
|
|---|
| 248 |
|
|---|
| 249 | make pot
|
|---|
| 250 | make update-po
|
|---|
| 251 |
|
|---|
| 252 | This will update the messages in all existing files in
|
|---|
| 253 | the .po/ directory.
|
|---|
| 254 |
|
|---|
| 255 |
|
|---|
| 256 |
|
|---|
| 257 | 4. TRANSLATE MESSAGES
|
|---|
| 258 |
|
|---|
| 259 | In the links section at bottom of this page you find references to the
|
|---|
| 260 | 'kbabel' and 'poEdit' software to easily translate the message files.
|
|---|
| 261 |
|
|---|
| 262 | Run 'kbabel' or equivalent program
|
|---|
| 263 | kbabel ./po/grasslibs_<LANGUAGE>.po
|
|---|
| 264 | kbabel ./po/grassmods_<LANGUAGE>.po
|
|---|
| 265 | kbabel ./po/grasswxpy_<LANGUAGE>.po
|
|---|
| 266 |
|
|---|
| 267 | For example (German):
|
|---|
| 268 | kbabel ./po/grasslibs_de.po
|
|---|
| 269 | kbabel ./po/grassmods_de.po
|
|---|
| 270 | kbabel ./po/grasswxpy_de.po
|
|---|
| 271 |
|
|---|
| 272 | KBABEL: You may load .po files from other projects [see footnote 1].
|
|---|
| 273 | Then use TOOLS -> ROUGH TRANSLATION to auto-translate messages.
|
|---|
| 274 | For Asian, Indian and other keymaps, see [footnote 3].
|
|---|
| 275 |
|
|---|
| 276 | NOTES:
|
|---|
| 277 | * Pay attention to keep '%s', '\n' and other stuff also
|
|---|
| 278 | in the translated messages!
|
|---|
| 279 |
|
|---|
| 280 | * Please use 'ISO-8859-1' or 'ISO-8859-15' for western languages.
|
|---|
| 281 | See http://en.wikipedia.org/wiki/ISO_8859 for details.
|
|---|
| 282 |
|
|---|
| 283 | After finishing the translation, save the files.
|
|---|
| 284 |
|
|---|
| 285 |
|
|---|
| 286 | 5. CREATE MO FILES
|
|---|
| 287 |
|
|---|
| 288 | run
|
|---|
| 289 | make mo
|
|---|
| 290 |
|
|---|
| 291 | READY.
|
|---|
| 292 |
|
|---|
| 293 |
|
|---|
| 294 | 6. Now recompile, install and run GRASS.
|
|---|
| 295 | It should work :-)
|
|---|
| 296 |
|
|---|
| 297 | If you don't have this possibility, just skip this step.
|
|---|
| 298 |
|
|---|
| 299 | 7. Send the updated .po files to a GRASS Development Team member.
|
|---|
| 300 | If possible, please send diffs against CVS:
|
|---|
| 301 | svn diff grasslibs_LANG.po > grasslibs_LANG_po.diff
|
|---|
| 302 | svn diff grassmods_LANG.po > grassmods_LANG_po.diff
|
|---|
| 303 | svn diff grasswxpy_LANG.po > grasswxpy_LANG_po.diff
|
|---|
| 304 |
|
|---|
| 305 | If you updated .c files with _() macros as explained
|
|---|
| 306 | above, please send C file diffs against SVN:
|
|---|
| 307 |
|
|---|
| 308 | svn diff file.c > file.diff
|
|---|
| 309 |
|
|---|
| 310 | Thanks for submitting.
|
|---|
| 311 |
|
|---|
| 312 |
|
|---|
| 313 | PLEASE HELP TO TRANSLATE GRASS MESSAGES!
|
|---|
| 314 |
|
|---|
| 315 | ----------------------------------------------
|
|---|
| 316 |
|
|---|
| 317 | LINKS
|
|---|
| 318 |
|
|---|
| 319 | - KBabel: http://i18n.kde.org/tools/kbabel/
|
|---|
| 320 | - poEdit: http://poedit.sourceforge.net/
|
|---|
| 321 | - *.po files for many languages: KDE translator center, http://i18n.kde.org/teams/
|
|---|
| 322 |
|
|---|
| 323 | NOTES
|
|---|
| 324 |
|
|---|
| 325 | [1] To load existing .po files (eg from older GRASS versions or
|
|---|
| 326 | KDE translator center, http://i18n.kde.org/teams/) into
|
|---|
| 327 | Kbabel, use
|
|---|
| 328 | KBABEL -> SETTINGS -> CONFIGURE DIRECTORY -> PO AUXILIARY
|
|---|
| 329 |
|
|---|
| 330 | [2] To use QGIS' TS files, you have to convert them to PO format.
|
|---|
| 331 | TS files -> PO files converter:
|
|---|
| 332 | To translate the .ts files e.g. from QGIS to .po files,
|
|---|
| 333 | use
|
|---|
| 334 | http://oss.erdfunkstelle.de/ts2msg/index.shtml
|
|---|
| 335 |
|
|---|
| 336 | cd qgis/i18n
|
|---|
| 337 | ts2msg utf8 qgis_de.ts
|
|---|
| 338 | -> qgis_de.po
|
|---|
| 339 |
|
|---|
| 340 | [3] To change/add the keymap under KDE, you have to:
|
|---|
| 341 | 1. Open "(KDE) Control Center = kcontrol"
|
|---|
| 342 | 2. Go to Regional & Accessibility -> Keyboard Layout
|
|---|
| 343 | 3. Check "Enable Keyboard Layout".
|
|---|
| 344 | 4. Select Layout (e.g. Hindi) from the Additional Layouts list
|
|---|
| 345 | 5. Press "Add >>"
|
|---|
| 346 | 6. Press "Apply".
|
|---|
| 347 |
|
|---|
| 348 | Note!: You can change between the new and the original layouts by
|
|---|
| 349 | pressing Alt+Ctrl+k or by clicking the keyboard icon in the system
|
|---|
| 350 | tray.
|
|---|
| 351 |
|
|---|
| 352 | Command line alternative:
|
|---|
| 353 | # hindi layout (Devanagari)
|
|---|
| 354 | setxkbmap -model -layout dev -variant basic
|
|---|
| 355 | # back to US layout:
|
|---|
| 356 | setxkbmap -model -layout us -variant basic
|
|---|
| 357 |
|
|---|
| 358 | How to use the keyboard
|
|---|
| 359 |
|
|---|
| 360 | http://indlinux.org/keymap/keymaps.php
|
|---|