phpGroupWare is built using a multi-language support scheme. This means the pages can be translated to other languages very easily. Translations of text strings are stored in the phpGroupWare database, and can be modified by the phpGroupWare administrator.
The lang() function is your application's interface to phpGroupWare's internationalization support. While developing your application, just wrap all your text output with calls to lang(), as in the following code:
$x = 42; echo lang("The counter is %1",$x)."<br>"; |
lang($key, $m1="", $m2="", $m3="", $m4="", $m5="", $m6="", $m7="", $m8="", $m9="", $m10="")
is the string to translate and may contain replacement directives of the form %n.
is the first replacement value or may be an array of replacement values (in which case $m2 and above are ignored).
- $m10/ the 2nd through 10th replacement values if $m1 is not an array.
An application called Transy is being developed to make this easier, until then you can create the translation data manually.
The translation class uses the lang table for all translations. We are concerned with 4 of the columns to create a translation:
The key to identify the message (the $key passed to the lang() function). This is written in English.
The application the translation applies to, or common if it is common across multiple applications.
The code for the language the translation is in.
The translated string.
Currently all applications, and the core phpGroupWare source tree have a lang.sql file. This is the place to add translation data. Just add lines of the form:
REPLACE INTO lang (message_id, app_name, lang, content) VALUES( 'account has been deleted','common','en','Account has been deleted'); |
If you browse through the phpGroupWare sources, you may notice a pattern to the return codes used in the higher-level functions. The codes used are partially documented in the doc/developers/CODES file. Codes are used as a simple way to communicate common error and progress conditions back to the user. They are mapped to a text string through the check_code() function, which passes the strings through lang() before returning. For example, calling
echo check_code(13); |