Permalink
Please
sign in to comment.
Browse files
Gettext support!
For starters, the main menu is now translatable.
More strings may be made translatable by including "translations.h",
then surrounding strings to translate with _().
For example: add_msg("my message") becomes add_msg(_("my message")).
Instructions for translating, and maintaining translation files,
can be found in TRANSLATING.md.- Loading branch information...
Showing
with
118 additions
and 19 deletions.
- +87 −0 TRANSLATING.md
- +5 −1 main.cpp
- +19 −18 main_menu.cpp
- +7 −0 translations.h
| @@ -0,0 +1,87 @@ | |||
| Info on translating Cataclysm-DDA into another language. | |||
|
|
|||
|
|
|||
| TRANSLATORS | |||
| =========== | |||
|
|
|||
| If there is already a translation available for your language, | |||
| and you just want to update or improve it, | |||
| you can edit the .po file for your language, | |||
| found inside the "lang/po" subdirectory. | |||
|
|
|||
| After editing this file, | |||
| if you are running the dev version and want to test your changes, | |||
| perform step 4 from the maintainers section below. | |||
|
|
|||
|
|
|||
| If there is no translation yet, | |||
| the .po file will need to be generated. | |||
| You can do this yourself by following the instructions below, | |||
| or ask one of the CleverRaven devs to do it for you. | |||
|
|
|||
| When you are done translating, | |||
| submit the changes back to CleverRaven for inclusion in Cataclysm-DDA. | |||
|
|
|||
|
|
|||
| MAINTAINERS | |||
| =========== | |||
|
|
|||
|
|
|||
| Step 1: Extract the translatable strings | |||
| ---------------------------------------- | |||
|
|
|||
| First we use "xgettext" to find all the translatable strings in the source code, | |||
| and store them in the file "cataclysm-dda.pot", | |||
| in the lang/po subdirectory. | |||
|
|
|||
| This needs to be done every time translatable strings are added or modified. | |||
| All of the translations depend on this file. | |||
|
|
|||
| xgettext -d cataclysm-dda -s -o lang/po/cataclysm-dda.pot --keyword=_ *.cpp | |||
| Step 2(a): Initialize each language file | |||
| ---------------------------------------- | |||
| If we're starting a new translation from scratch, | |||
| we have to initialize the translation file. | |||
| In this example the translation is into British English (en_UK). | |||
| For other languages change "en_UK" to the relevant language identifier. | |||
| msginit -l en_UK.utf8 -o lang/po/en_UK.po -i lang/po/cataclysm-dda.pot | |||
| Step 2(b): Update an already existing language file | |||
| --------------------------------------------------- | |||
| If we just want to update a translation, | |||
| we'll want to keep all the messages that have already been translated. | |||
| In this case we use "msgmerge" in stead of "msginit". | |||
| msgmerge -s -U lang/po/en_UK.po lang/po/cataclysm-dda.pot | |||
| Step 3: Translate | |||
| ----------------- | |||
| Now open the .po file in your favorite editor and translate! | |||
| The lines beginning with "msgid" must be left in the english form, | |||
| only the lines beginning with "msgstr" should be translated. | |||
| Step 4: Compile the .po file | |||
| ---------------------------- | |||
| If it is a new translation, | |||
| you will need to create a subdirectory in lang/mo for it, | |||
| and then a subdirectory called "LC_MESSAGES" inside that. | |||
| For example: | |||
| mkdir lang/mo/en_UK/LC_MESSAGES | |||
| Now run the "msgfmt" program to compile the translations for use in game. | |||
| msgfmt -c -o lang/mo/en_UK/LC_MESSAGES/cataclysm-dda.mo lang/po/en_UK.po | |||
| Hooray, that's it :). | |||
| @@ -0,0 +1,7 @@ | |||
| #ifndef _TRANSLATIONS_H_ | |||
| #define _TRANSLATIONS_H | |||
|
|
|||
| #include <libintl.h> | |||
| #define _(STRING) gettext(STRING) | |||
|
|
|||
| #endif // _TRANSLATIONS_H_ | |||
0 comments on commit
377bac9