Forum OpenACS Development: Rules for writing code: I18N

Posted by Malte Sussdorff on
DISCLAIMER: Sarcasm included in this posting.

I take it that most people do not like to write I18N enabled code. Though this sucks, we have to face realities that most developers in the community are native english speakers and therefore not have much intention to deal with the additional burden of I18N code for their clients.


You could make it at least easier for someone like me to translate the files.

Here is a list of things that you can do:

- If you have a label/pretty_name or any other string, use "" instead {} or nothing at all. Using "" at least allows me to go quickly through the code and search/replace. This is in .tcl files.

-- set label Information (BAD)
-- set label "Information" (good)
-- set label {Information System} (BAD)
-- set label "Information System" (good)
-- display_template {Information System} (BAD)
-- display_template {[_ yourpackage.Information_System]} (very good!)

- Don't even *THINK* about adding english terms in SQL Files. Look for a TCL API to achieve what you want to do. A sql file should only contain table creation information and *maybe* some plsql code. For most packages that currently exist this is not necessary anymore due to the CR TCL API, but if you write new code, make life easy for everyone and use these APIs 😊.

I guess this should make it into the developers guidelines at one point in time, but for now it is in the forum and hopefully some developers will read it and adhere to it :).

Posted by Malte Sussdorff on
Here is a step by step guide how I write new code (for TCL files):

- Write the code with English terms.
- Replace all the English terms with "<#_ fill in the english term here#>"
- Go to the APM, Go to the package, Click on I18N, click on "Replace .... ", click on "Show TCL Files".
- Select the TCL file you have been editing and press OK.

OpenACS is smart enough to create a message key out of your English term and store it in the database (and catalog files). It will even check if your English Term can be found in acs-kernel.common and use the common string instead.

Posted by Nick Carroll on
Perhaps a valid entry for the "Tips Blog"?
Posted by Andrew Piskorski on
Malte, using {This is a literal string.} is good Tcl style. Why exactly should OpenACS developers avoid using it? I don't particular understand your "easier for me to manually search and replace" reason.
Posted by Malte Sussdorff on
Andrew, you should quote a string with "" (at least that's what I learned 12 years back ...). I'm not sure why this should be otherwise in TCL.

Reason is fairly simple. If you would do a search/replace from "{" to "<#_ " then you would have to skip ton's of code.

But if you just search for " and replace it, then you can do it much faster.