Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-4402

Gettext. Translation. Usage of context function.

XMLWordPrintable

      I decided to do the experiments and select the best style to write translatable strings in context with/without comments.

      Tested:
      1. Pootle
      2. Virtaal
      3. Lokalize
      4. Poedit
      See attached pictures.

      Considered two different styles of source code.
      a) on top of the pictures:
      // GETTEXT: button for switch pages
      $pagespan = new CSpan('<< '._x('First', 'page'), 'darklink');

      b) bottom of the picture:
      $pagespan = new CSpan(_x('Last', 'context: page').' >>', 'darklink');

      In the case a) I used short context definition ('page') and the comment for gettext.
      In the case b) I used more complex context definition ('context: page') without the comment for gettext.

      We need to discuss and select the best style regarding to save source code clear and to give for translators as much help as possible.

      My personal conclusion:

      • usage only context is not enough in most cases, so need to use comments too where context is used. But it's not hard rule, it's recommendation.
      • usage the fixed part "context: " as prefix for all context strings helps to read source code and to use all mentioned tools tor translation.

      So I propose the style:
      // GETTEXT: button for switch pages
      $pagespan = new CSpan('< '._x('Previous', 'context: page'), 'darklink');

      See corresponding attached picture.

      According to the "best style" a patch prepared.
      Next patches will be prepared after approving current style or select another.

      Documentation will be updated:
      http://www.zabbix.com/documentation/2.0/contrib/frontend_localisation#code_conventions

      p.s. some bad comment was fixed in the patch:
      The comment format of "// GETTEXT: r is date format string as described in http://php.net/date"
      was changed to "/* */" because this comment really was used for the word "Updated" but not for the word "r"

        1. context1.diff
          10 kB
        2. 4. poedit.png
          4. poedit.png
          16 kB
        3. 3. lokalize.png
          3. lokalize.png
          40 kB
        4. 2. virtaal.png
          2. virtaal.png
          11 kB
        5. 1. pootle.png
          1. pootle.png
          23 kB

            Unassigned Unassigned
            zalex_ua Oleksii Zagorskyi
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: