Forum OpenACS Development: I18N - A sample internationalisation package

Index

Design and Requirements

keyphrases was designed to generate language independent templates for the UNIDO. Therefore it requires the UNIDO Content Package to be pre-installed (actually it only uses the languages-table, so perhaps in later versions we will fix this dependency). For any string you wish to have language independant you create a keyphrase set (having a unique keyphrase_id). Each keyphrase set can have a keyphrase for each language. The only restriction for keyphrases is, that there MUST NOT BE two keyphrases being equal and of the same language.

Also implemented are SmartURLs for language preferences. Like your.server.com/en/some_dir will link to your.server.com/some_dir and set the language preference (ad_conn language) to en (English).

Back to top

Syntax

Directly put into ADP-pages: @!where_particle;what_particle!@ where_particle will be a string searched for in language_code or # (then specifying the number). what_particle will be the number or string found in the database. The whole thing will be substituted by the keyphrase of corresponding language with the same number as specified or as the specified keyphrase has.

Alternatively you may specify [template::get_keyword where_particle what_particle] in TCL code.

examples:
\@!#;{1234}!@ will be substituted by a keyphrase of keyphrase set #1234.
\@!en;{contact}!@ will be substituted by a keyphrase of the same keyphrase set where the English keyphrase is "contact".
[template::get_keyword fr lunedi] will be substituted by a keyphrase of the same keyphrase set where the French keyphrase is "lunedi".

Note: Because of OACS 4.7 i18n, the syntax me be changed in subsequent versions!

Back to top

Templates

If the syntax above does not provide for enough flexibility for the page (e. g. for Arabic the page has to be changed completely), then use language specific templates.

For every language you wish to have an independant template, just add a file called "file.language", where "file" is the filename and "language" is an abbreviation like en, fr, de etc (e. g. test.fr). If ServeLanguageSpecificTemplateP is set to 1, then this feature becomes active. If "file.current_language" where "current_language" is the abbreviation for the language the user prefers exists, this file is served as template. Else the standard "file.adp" will be served as template.

All language specific templates, will be treated exactly as if they where an adp page.

Note: Such language specific templates also may be defined for any master template.

Back to top

Parameters

There are three parameters for this package:

  • ThrowErrorP
  • DefaultLanguage
  • ServeLanguageSpecificTemplateP

ThrowErrorP can have the values 0 (deactivated) and 1 (activated). If ThrowErrorP is active, then every keyphrase that is not found in the database will result in an TCL error. If deactivated the site will load and be displayed, but error messages will fill the spaces, where the keyphrases that produced errors were.

DefaultLanguage If no language preference can be identified, than the value for DefaultLanguage is used. Make sure DefaultLanguage is a correct language abbreviation (e. g. en, de, fr, it) like in the table languages.language_code

IMPORTANT! If you use the parameters screen to change the DefaultLanguage this will have only a partially effect. Use the option in the index or run the update script from the index afterwards!

ServeLanguageSpecificTemplateP can have the values 0 (deactivated) and 1 (activated). If active, the request processor will try to serve file.language as template. See Templates for details.

Back to top

Collapse
Posted by Thomas Taylor on
If you want to use this package, but obviously do not have the unido content package, just do the following AFTER initiating i18n: CREATE TABLE unido_languages AS SELECT language_name, language_code, active_p as un_language_p FROM languages

However, this package has never been tested on a machine without the unido content package. If you run into any trouble or want to suggest changes, etc... just send a mail to mailto:mainmail@chello.at
I'll be glad to help!

Collapse
Posted by Thomas Taylor on
Whoever downloaded the I18N package before 2003-04-30 12:00h, please download it again, because there have been some vital changes!

However there still may be some problems when installing:

If you encounter request errors that include these phrases:
unknown command "language"
[ad_i18n_id]
Then restart the AOL-Server or reload the TCL files of the i18n package.

If your request error looks something like this:
Database operation "0or1row" failed (exception NSDB, "Query was not a statement returning rows.")
    while executing
"ns_pg_bind 0or1row nsdb0 {select language_name as default_lang from languages where language_code = :default_lang_code}"
Then the data model has not been installed! Please run i18n-create.sql manually! (I do not understand this error, because i18n-create.sql is detected as file type data_model_create.)

If your APM does not support auto mount (APM version BEFORE 4.6.2) then you have to mount this service manually to enter keyphrases into the database.

Whenever you encounter some request errors, where a table named unido_languages is missing do as written in the posting above!

I hope this will help and probably somebody can explain to me, why the hell my data model does not get loaded sometimes.

Collapse
Posted by VenuMadhav Deevi on
Hi
  I had downloaded the newer version of i18n-1.0.apm and tried to install into my openACS packages using package manager. I am using PostgreSql as database. I got an error while installing the error was

Error:-
/***********************************************************/
Please wait while the installer loads ........

Done.

No New Packages to Install
There are no new packages to install. Please load some using the Package Loader.

Return to the APM.

Incompatible Packages
Package "Internationalisation" (i18n) doesn't support postgresql.

/***********************************************************/

Plz give me a solution as soon as possible.

With Regards

Venu Madhav Deevi

Collapse
Posted by Don Baccus on
Have you looked at the OACS 5.0 (what we earlier called 4.7, I should post our current view of the numbering system when I get a chance, we discussed it at Copenhagen) stuff closely?

There seems to be a lot of overlap but not full overlap.  In particular our current effort doesn't include custom language templates and that may be something we want to merge in.

Also OACS 5.0 doesn't provide "smart URLs".  However I've done this for Greenpeace so might want to compare your implementation with mine.  The Greenpeace solution includes admin UI to allow a regional organization to define which languages are legal for each subsite, and the request processor only allows these defined mappings (using cached data so there's no db lookup involved.)  So it might be a bit more complete than your implementation which, from your description, is oriented more towards implementing one scheme for the entire site without consideration of subsite specific needs.  Am I right?

This looks like interesting work, yes.  Hopefully we can all coordinate as the OACS 5.0 effort ramps up over the next few weeks.

Collapse
Posted by Thomas Taylor on
I have to admit, that I did not have too close a look at OACS 5.0. The thing is, the smart URLs part has been done by Tilmann Singer, who - as far as I know - adapted your code from Greenpeace. Our implementation does not distinguish subsites.

The package is not properly finished as such. As it was developed for UNIDO it is tightly intervowen with the unido content package, and as I learned that there is an i18n coming up with OACS 5.0 there should be no need to do such a package twice.
If I can be of help in any way, let me know.