Index: openacs-4/packages/acs-core-docs/www/i18n.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-core-docs/www/i18n.html,v diff -u -r1.5 -r1.6 --- openacs-4/packages/acs-core-docs/www/i18n.html 21 Oct 2003 10:04:47 -0000 1.5 +++ openacs-4/packages/acs-core-docs/www/i18n.html 28 Oct 2003 22:07:34 -0000 1.6 @@ -1,4 +1,4 @@ -
+
By Peter Marklund and Lars Pind
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 still processed.
+
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 still processed.
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 @@ -101,9 +101,9 @@
Here are a couple of examples. Say we have the following two parameters, taken directly from the dotlrn package. -
Table�13.1.�
Parameter Name | Parameter Value |
---|---|
class_instance_pages_csv | #dotlrn.class_page_home_title#,Simple 2-Column;#dotlrn.class_page_calendar_title#,Simple 1-Column;#dotlrn.class_page_file_storage_title#,Simple 1-Column |
departments_pretty_name | #departments_pretty_name# |
+
Table�11.1.�
Parameter Name | Parameter Value |
---|---|
class_instance_pages_csv | #dotlrn.class_page_home_title#,Simple 2-Column;#dotlrn.class_page_calendar_title#,Simple 1-Column;#dotlrn.class_page_file_storage_title#,Simple 1-Column |
departments_pretty_name | #departments_pretty_name# |
Then, depending on how we retrieve the value, here's what we get: -
Table�13.2.�
Command used to retrieve Value | Retrieved Value |
---|---|
parameter::get -localize -parameter class_instances_pages_csv | Kurs Startseite,Simple 2-Column;Kalender,Simple 1-Column;Dateien,Simple 1-Column |
parameter::get -localize -parameter departments_pretty_name | Abteilung |
parameter::get -parameter departments_pretty_name | #departments_pretty_name# |
+
Table�11.2.�
Command used to retrieve Value | Retrieved Value |
---|---|
parameter::get -localize -parameter class_instances_pages_csv | Kurs Startseite,Simple 2-Column;Kalender,Simple 1-Column;Dateien,Simple 1-Column |
parameter::get -localize -parameter departments_pretty_name | Abteilung |
parameter::get -parameter departments_pretty_name | #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 for localization to happen you must use the -localize flag. @@ -151,7 +151,7 @@ Use the *_pretty version in your ADP page.
To internationalize numbers, use lc_numeric $value, which formats the number using the appropriate decimal point and thousand separator for the locale. -
When coding forms, remember to use message keys for each piece of text that is user-visible, including form option labels and button labels.
When coding forms, remember to use message keys for each piece of text that is user-visible, including form option labels and button labels.
Acs-lang includes tools to automate some internationalization. From /acs-admin/apm/, select a package and then click on @@ -240,9 +240,9 @@ with the appropriate notation for the type of file, and store the text in the message catalog. You need to run the process twice, once for ADP files, and once for Tcl files. -
Find datetime in .xql files. Use command line tools to find suspect SQL code:
grep -r "to_char.*H" * +
Find datetime in .xql files. Use command line tools to find suspect SQL code:
grep -r "to_char.*H" * grep -r "to_date.*H" *
In SQL statements, replace the format string with the ANSI standard format, YYYY-MM-DD HH24:MI:SS and change the field name to *_ansi so that it cannot be confused with previous, improperly formatting fields. For example,
to_char(timestamp,'MM/DD/YYYY HH:MI:SS') as foo_date_pretty
becomes
to_char(timestamp,'YYYY-MM-DD HH24:MI:SS') as foo_date_ansi
In TCL files where the date fields are used, convert the datetime from local server timezone, which is how it's stored in the database, to the user's timezone for display. Do this with the localizing function lc_time_system_to_conn:
set foo_date_ansi [lc_time_system_to_conn $foo_date_ansi]
When a datetime will be written to the database, first convert it from the user's local time to the server's timezone with lc_time_conn_to_system.