jami-docs

Forked version of Jami documentation, see wrycode.com/jami-docs-demo
git clone git://git.wrycode.com/wrycode/jami-docs.git
Log | Files | Refs

chatview-i18n-(design-draft).md (3103B)


      1 # chatview internationalization
      2 
      3 Note: Had to delete broken image links; page is probably out of date
      4 
      5 The GNOME client's chatview lacks proper i18n support.
      6 
      7 Related bug report: https://git.jami.net/savoirfairelinux/ring-client-gnome/issues/900
      8 
      9 first ideas:
     10 
     11 * i18n functions provided by separate js library
     12 * i18n not trivial, overhead of custom code extremely high => use existing js lib
     13 * library will be embedded into the client => code base should be as mature as possible
     14 * ideally the translation process would be exactly the same as for the C++ code
     15 
     16 # in short
     17 
     18 (1) either
     19 
     20 C++ tells JS code which language is currently used and JS code loads translations
     21 
     22 (2) or
     23 
     24 C++ loads translations and passes them to JS code together with info about currently used language
     25 
     26 # review exisiting js i18n libs
     27 
     28 ## [i18next](https://www.i18next.com/)
     29 
     30 **The good**
     31 
     32 * very mature
     33 * huge user base
     34 * lots of documentation
     35 * No runtime dependencies
     36 
     37 **The bad**
     38 
     39 * huge, overkill ?
     40 * uses own JSON format not gettext .mo
     41 
     42 This will require translation of .po files to JSON format (using [i18next-gettext-converter](https://github.com/i18next/i18next-gettext-converter)).
     43 
     44 **The ugly**
     45 
     46 * keys do not have the same meaning as gettext keys (see [this thread](https://stackoverflow.com/questions/19403787/gettext-style-keys-with-i18next-and-general-workflow)), this might be very confusing for the translators
     47 * i18next-gettext-converter requires nodeJS as build dependency
     48 
     49 ## [jed](http://messageformat.github.io/Jed/)
     50 
     51 **The good**
     52 
     53 * looks quite mature
     54 * good user base
     55 * provides gettext API (will be very intuitive to translators)
     56 * No runtime dependencies
     57 
     58 **The bad**
     59 
     60 * not very active currently (but it might very well just be stable)
     61 * uses own JSON format not gettext .mo
     62 
     63 This will require translation of .po files to JSON format (e.g. using [po2json](https://github.com/mikeedwards/po2json)).
     64 po2json also requires nodeJS as dependency, **but** it is [available as Debian package](https://packages.debian.org/stable/javascript/node-po2json), which makes it slightly less annoying
     65 
     66 Source: [Internationalization in JavaScript](http://www.jeromesteunou.net/internationalisation-in-javascript.html)
     67 
     68 ## [Polyglot](http://airbnb.io/polyglot.js/)
     69 
     70 **The good**
     71 
     72 * developed by airbnb, well maintained
     73 * good user base
     74 
     75 **The bad**
     76 
     77 * uses own JSON format not gettext .mo
     78 
     79 **The ugly**
     80 
     81 * runtime dependency on nodeJS
     82 
     83 # using Jed
     84 
     85 * patch draft:
     86 
     87 https://gerrit-ring.savoirfairelinux.com/c/ring-client-gnome/+/10615
     88 
     89 * Retrieve strings:
     90 
     91 ```
     92 $ cd po/chatview
     93 $ xgettext -o ring-client-gnome-chatview.pot -L Javascript --from-code=utf-8 -D ../../ -f POTFILES.in
     94 
     95 ```
     96 
     97 * Translate them:
     98 
     99 ```
    100 $ cp ring-client-gnome-chatview.pot en.po
    101 $ cp ring-client-gnome-chatview.pot fr.po
    102 # translate ...
    103 ```
    104 
    105 * Install po2json:
    106 
    107 ```
    108 $ apt-get install node-po2json
    109 
    110 ```
    111 
    112 * Generate JSON files:
    113 
    114 ```
    115 $ ./scripts/build-chatview-locales.sh web/i18n
    116 ```
    117 
    118 That's it. JSON translations are loaded as gresource. The `webkitchatcontainer` class calls `init_i18n()`, passing appropriate translation resources to the chatview.