Index: openacs-4/packages/acs-core-docs/www/i18n-introduction.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-core-docs/www/i18n-introduction.html,v diff -u -r1.18.2.7 -r1.18.2.8 --- openacs-4/packages/acs-core-docs/www/i18n-introduction.html 19 Nov 2016 09:21:53 -0000 1.18.2.7 +++ openacs-4/packages/acs-core-docs/www/i18n-introduction.html 6 Jan 2017 09:18:41 -0000 1.18.2.8 @@ -33,7 +33,7 @@ which are static and mostly text, it may be easier to create a new ADP page for each language. In this case, the pages are distinguished by a file naming convention. -

User Content

OpenACS does not have a general system for supporting multiple, localized versions of user-input content. This document currently refers only to internationalizing the text in the package user interface.

Separate Templates for each Locale

If the request processor finds a file named filename.locale.adp, where locale matches the user's locale, it will process that file instead of filename.adp. For example, for a user with locale tl_PH, the file index.tl_PH.adp, if found, will be used instead of index.adp. The locale-specific file should thus contain text in the language appropriate for that locale. The code in the page, however, should still be in English. Message keys are processed normally.

Message Catalogs

Message Keys in Template Files (ADP Files)

+

User Content

OpenACS does not have a general system for supporting multiple, localized versions of user-input content. This document currently refers only to internationalizing the text in the package user interface.

Separate Templates for each Locale

If the request processor finds a file named filename.locale.adp, where locale matches the user's locale, it will process that file instead of filename.adp. For example, for a user with locale tl_PH, the file index.tl_PH.adp, if found, will be used instead of index.adp. The locale-specific file should thus contain text in the language appropriate for that locale. The code in the page, however, should still be in English. Message keys are processed normally.

Message Catalogs

Message Keys in Template Files (ADP Files)

Internationalizing templates is about replacing human readable text in a certain language with internal message keys, which can then be dynamically replaced with real human language in @@ -52,7 +52,7 @@ The short: #package_key.message_key#

- The advantage of the short syntax is that it's short. It's + The advantage of the short syntax is that it's short. It's as simple as inserting the value of a variable. Example: <span>#</span>forum.title#

  • @@ -64,8 +64,8 @@ The verbose syntax allows you to specify a default text in a certain language. This syntax is not recommended anymore, but it can be convenient for development, because - it still works even if you haven't created the message - in the message catalog yet, because what it'll do is + it still works even if you haven't created the message + in the message catalog yet, because what it'll do is create the message key with the default text from the tag as the localized message. Example: <trn key="forum.title" locale="en_US">Title</trn> @@ -76,7 +76,7 @@

    This syntax has been designed to make it easy to internationalize existing pages. This is not a syntax that - stays in the page. As you'll see later, it'll be replaced + stays in the page. As you'll see later, it'll be replaced with the short syntax by a special feature of the APM. You may leave out the message_key by writing an underscore (_) character instead, in which case a message key will be @@ -88,8 +88,8 @@ \#package_key.message_key\#. In Tcl files all message lookups *must* be on either of the following formats:

    -

    • Typical static key lookup: [_ package_key.message_key] - The message key and package key used here must be string literals, they can't result from variable evaluation.

    • - Static key lookup with non-default locale: [lang::message::lookup $locale package_key.message_key] - The message key and package key used here must be string literals, they can't result from variable evaluation.

    • +

      • Typical static key lookup: [_ package_key.message_key] - The message key and package key used here must be string literals, they can't result from variable evaluation.

      • + Static key lookup with non-default locale: [lang::message::lookup $locale package_key.message_key] - The message key and package key used here must be string literals, they can't result from variable evaluation.

      • Dynamic key lookup: [lang::util::localize $var_with_embedded_message_keys] - In this case the message keys in the variable var_with_embedded_message_keys must appear as string literals \#package_key.message_key\# somewhere in the code. Here is an example of a dynamic lookup: set message_key_array { dynamic_key_1 \#package_key.message_key1\# @@ -162,7 +162,7 @@ # in curly braces (should return nothing, or possibly a few lines for inspection) find -iname '*.tcl'|xargs egrep -i '\{.*<#' -# Check if you've forgotten space between default key and text in message tags (should return nothing) +# Check if you've forgotten space between default key and text in message tags (should return nothing) find -iname '*.tcl'|xargs egrep -i '<#_[^ ]' # Review the list of tcl files with no message lookups @@ -171,19 +171,19 @@ When you feel ready you may vist your package in the package manager and run the action "Replace tags with keys - and insert into catalog" on the Tcl files that you've edited to + and insert into catalog" on the Tcl files that you've edited to replace the temporary tags with calls to the message lookup procedure.

        Dates, Times, and Numbers in Tcl files

        Most date, time, and number variables are calculated in Tcl files. Dates and times must be converted when stored in the database, when retrieved from the database, and when displayed. All dates - are stored in the database in the server's timezone, which is an + are stored in the database in the server's timezone, which is an APM Parameter set at /acs-lang/admin/set-system-timezone and readable at lang::system::timezone.. When retrieved from the database and displayed, dates and times must - be localized to the user's locale. + be localized to the user's locale.

      APM Parameters

      Some parameters contain text that need to be localized. In this case, instead of storing the real text in the parameter, @@ -198,7 +198,7 @@ Here are a couple of examples. Say we have the following two parameters, taken directly from the dotlrn package.

      Parameter NameParameter Value
      class_instance_pages_csv<span>#</span>dotlrn.class_page_home_title#,Simple 2-Column;<span>#</span>dotlrn.class_page_calendar_title#,Simple 1-Column;<span>#</span>dotlrn.class_page_file_storage_title#,Simple 1-Column
      departments_pretty_name<span>#</span>departments_pretty_name#

      - Then, depending on how we retrieve the value, here's what we get: + Then, depending on how we retrieve the value, here's what we get:

      Command used to retrieve ValueRetrieved Value
      parameter::get -localize -parameter class_instances_pages_csvKurs Startseite,Simple 2-Column;Kalender,Simple 1-Column;Dateien,Simple 1-Column
      parameter::get -localize -parameter departments_pretty_nameAbteilung
      parameter::get -parameter departments_pretty_name<span>#</span>departments_pretty_name#

      The value in the rightmost column in the table above is the value returned by an invocation of parameter::get. Note that