kaishiqi / I18N-Gettext-Supported

Parsing and use Gettext .mo files.
MIT License
22 stars 13 forks source link

I18N Gettext C++ and Lua Supported

Gettext is an internationalization and localization (i18n) system, commonly used for writing multilingual programs. However, here's supported classes working on parse binary .mo (Machine Object) files only. So, the supported classes is lightweight, free, easy to use. And It uses C++. It works on iOS, Android, OS X, Windows and Linux. And cocos2d-x supported. Finally, it is recommended to use Poedit to compile with into binary .mo files. (It is also a multi-platform)

Usage Tests


How to use Poedit


Presetting

  1. Download Poedit, install and open it.
  2. First, click File – Preferences, fill identity info.
  3. Switch to Editor tab, select Automatically compile .mo file on save and Show summary after catalog update.

New File

  1. Click File - New…, then select Lanaguage of the translation.
  2. Click Catalogue - Properties..., select Translation properties tab:
    • Project name and version: I18N Test 1.0 (example)
    • Plural Forms:If there is no special requirements then select Use default rules for this language. Note: Plural Forms is important, it is input class to used.
      //nplural=INTEGER; plural=EXPRESSION
      I18nUtils::getInstance()->addMO(..., [](int n){return EXPRESSION;}, INTEGER);
    • Charset:UTF-8 (recommended)
    • Source code charset:UTF-8 (recommended)
  3. Then save to you project resource directory. (Because after the Settings required to save first)
  4. Click Catalogue - Properties..., select Sources paths tab:
    • Base path: ../src (example) Note: ".." is parent directory, here is required to input relative path.
    • Paths: click add new, then input . .
  5. Click Catalogue - Properties..., select Sources keywords tab, add all supported keywords:
    • __
    • _x:1,2c
    • _n:1,2
    • _nx:1,2,4c
    • _n_noop:1,2
    • _nx_noop:1,2,3c
  6. Confirm and Save.

Usage Poedit

  1. First, use the keywords in the source file wrap string need to be translated.
  2. Open .po file, click on the Poedit main UI of Update button to parsing keywords in the source file.
  3. Translation the string and save, automatically compile .mo file on save.
  4. Load the .mo file in you project to be used.

Contact


E-mail: kaishiqi@icloud.com