Index: openacs-4/packages/acs-core-docs/www/i18n-convert.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-core-docs/www/i18n-convert.html,v diff -u -r1.26.2.15 -r1.26.2.16 --- openacs-4/packages/acs-core-docs/www/i18n-convert.html 6 Jan 2017 09:18:41 -0000 1.26.2.15 +++ openacs-4/packages/acs-core-docs/www/i18n-convert.html 2 Jun 2017 11:12:57 -0000 1.26.2.16 @@ -13,7 +13,7 @@ package and then click on Internationalization, then Convert ADP, Tcl, and SQL files to using the - message catalog.. This pass only changes the adp files; it does not affect catalog files or the catalog in the database.

You will now be walked through all of the selected adp pages. The UI shows you the intended changes and lets you edit or cancel them key by key.

  • Replace the temporary message tags in ADP files. From the same Convert ADP ... page in /acs-admin/apm as in the last step, repeat the process but deselect Find human language text ... and select Replace <# ... #> tags ... and click OK. This step replaces all of the temporary tags with "short" message lookups, inserts the message keys into the database message catalog, and then writes that catalog out to an xml file.

  • Replace human-readable text in Tcl files with temporary tags. Examine all of the tcl files in the packages for human-readable text and replace it with temporary tags. The temporary tags in Tcl are slightly different from those in ADP. If the first character in the temporary tag is an underscore (_), then the message keys will be auto-generated from the original message text. Here is an unmodified tcl file:

    +        message catalog..  This pass only changes the adp files; it does not affect catalog files or the catalog in the database.

    You will now be walked through all of the selected adp pages. The UI shows you the intended changes and lets you edit or cancel them key by key.

  • Replace the temporary message tags in ADP files. From the same Convert ADP ... page in /acs-admin/apm as in the last step, repeat the process but deselect Find human language text ... and select Replace <# ... #> tags ... and click OK. This step replaces all of the temporary tags with "short" message lookups, inserts the message keys into the database message catalog, and then writes that catalog out to an xml file.

  • Replace human-readable text in Tcl files with temporary tags. Examine all of the Tcl files in the packages for human-readable text and replace it with temporary tags. The temporary tags in Tcl are slightly different from those in ADP. If the first character in the temporary tag is an underscore (_), then the message keys will be auto-generated from the original message text. Here is an unmodified Tcl file:

     set title "Messages for $a(name) in $b(label)"
     set context [list [list . "SimPlay"] \
                       [list [export_vars -base case-admin { case_id }] \ 
    @@ -26,7 +26,7 @@
                         <#_ Administer %a.name%#>] \
                       <#_ Messages for %a.name%#>]
     

    Note that the message key case_admin_page_title was manually selected, because an autogenerated key for this text, with its substitute variables, would have been very confusing -

  • Replace the temporary message tags in Tcl files. Repeat step 2 for tcl files. Here is the example Tcl file after conversion:

    +

  • Replace the temporary message tags in Tcl files. Repeat step 2 for Tcl files. Here is the example Tcl file after conversion:

     set title [_ simulation.admin_title]
     set context [list [list . [_ simulation.SimPlay]] \
                       [list [export_vars -base case-admin { case_id }] \
    @@ -60,7 +60,7 @@
             message lookups in tcl, adp, and info files and the set of keys in
             the catalog file are identical.  The scripts below assume that
             message lookups in adp and info files are on the format
    -        \#package_key.message_key\#, and that message lookups in tcl files
    +        \#package_key.message_key\#, and that message lookups in Tcl files
             are always is done with one of the valid lookups described above. The script further assumes
             that you have perl installed and in your path.  Run the script like
             this:
    @@ -72,7 +72,7 @@
             test. If you don't provide the package_key argument then all
             packages with catalog files will be checked. 
             The script will run its checks primarily on en_US xml catalog files.
    -      

  • Avoiding common i18n mistakes

    Avoiding common i18n mistakes

    • Replace complicated keys with longer, simpler keys. When writing in one language, it is possible to create clever code to make correct text. In English, for example, you can put an if command at the end of a word which adds "s" if a count is anything but 1. This pluralizes nouns correctly based on the data. However, it is confusing to read and, when internationalized, may result in message keys that are both confusing and impossible to set correctly in some languages. While internationalizing, watch out that the automate converter does not create such keys. Also, refactor compound text as you encounter it.

      The automated system can easily get confused by tags within message texts, so that it tries to create two or three message keys for one long string with a tag in the middle. In these cases, uncheck those keys during the conversion and then edit the files directly. For example, this code:

        <p class="form-help-text"><b>Invitations</b> are sent,
                 when this wizard is completed and casting begins.</p>

      has a bold tag which confuses the converter into thinking there are two message keys for the text beginning "Invitations ..." where there should be one:

      Instead, we cancel those keys, edit the file manually, and put in a single temporary message tag:

        <p class="form-help-text"> <#Invitations_are_sent <b>Invitations</b> are sent, 
       when this wizard is completed and casting begins.#>
         </p>

      Complex if statements may produce convoluted message keys that are very hard to localize. Rewrite these if statements. For example:

      Select which case <if @simulation.casting_type@ eq "open">and
      @@ -157,6 +157,6 @@
       <msg key="Fix_1">for</msg>
       <msg key="Fix_2">for Bugs</msg>

      Another example: Bug-tracker component maintainer was converted to [_ bug-tracker.Bug-tracker]. Instead, it should be bug_tracker_component_maintainer.

    • Translations in Avoid "clever" message reuse. Translations may need to differ depending on the context in which the message appears. -

    • Avoid plurals. Different languages create plurals differently. Try to avoid keys which will change based on the value of a number. OpenACS does not currently support internationalization of plurals. If you use two different keys, a plural and a singular form, your application will not localize properly for locales which use different rules or have more than two forms of plurals.

    • Quoting in the message catalog for tcl. Watch out for quoting and escaping when editing text that is also code. For example, the original string

      set title "Patch \"$patch_summary\" is nice."

      breaks if the message text retains all of the escaping that was in the tcl command:

      <msg>Patch \"$patch_summary\" is nice.</msg>

      When it becomes a key, it should be:

      <msg>Patch "$patch_summary" is nice.</msg>

      Also, some keys had %var;noquote%, which is not needed since those +

    • Avoid plurals. Different languages create plurals differently. Try to avoid keys which will change based on the value of a number. OpenACS does not currently support internationalization of plurals. If you use two different keys, a plural and a singular form, your application will not localize properly for locales which use different rules or have more than two forms of plurals.

    • Quoting in the message catalog for tcl. Watch out for quoting and escaping when editing text that is also code. For example, the original string

      set title "Patch \"$patch_summary\" is nice."

      breaks if the message text retains all of the escaping that was in the Tcl command:

      <msg>Patch \"$patch_summary\" is nice.</msg>

      When it becomes a key, it should be:

      <msg>Patch "$patch_summary" is nice.</msg>

      Also, some keys had %var;noquote%, which is not needed since those variables are not quoted (and in fact the variable won't even be recognized so you get the literal %var;noquote% in the output).

    • Be careful with curly brackets. Code within curly brackets isn't evaluated. Tcl uses curly brackets as an alternative way to build lists. But Tcl also uses curly brackets as an alternative to quotation marks for quoting text. So this original code

      array set names { key "Pretty" ...} 

      ... if converted to

      array set names { key "[_bug-tracker.Pretty]" ...} 

      ... won't work since the _ func will not be called. Instead, it should be

      array set names [list key [_bug-tracker.Pretty] ...]