Frequently Asked Questions v2
|FAQ Main / Answer Detail|
Author: Jakub Adamek email@example.com
(c) Jakub Adámek, Econnect, January 2003
Since January 17 2003 AA is using the mini-gettext language environment. The
language files are in the directory
Each file is connected with one language and a series of PHP scripts. At run-time,
you can only use one file for translations at a time, but you can change freely
between files by using the
bind_mgettext_domain() function in
The files are maintained by people — translators and by the PHP function
add new translations and xmgettext() adds new strings to be translated which
it finds in the source files.
To add new translations, you only need to find empty strings
in your language files, e.g.
$_m["not yet translated"] = "".
Please mind some following notes.
The language files are regular PHP files, you must not break the syntax. You must not change the ID string in _m["..."]. Even if it contains bad English, it may be changed only in the source code, not in the language file. There is also an English translations file, thus small changes may take place there.
You must follow the PHP syntax for strings, using
\$ instead of
$. You must quote the
"". (You might quote it with single quotes as
well, but next time
xmgettext() will be run, it will reformat
all strings to double quotes.)
Each language string is preceded by links to source code where it is used.
If you are not sure how to translate a string, go to the source code and have
a look. Some language strings contain parameters
%1,%2 etc. which
will be replaced by some variable content at run-time. Place the parameters
appropriately in the translation.
The file begins with a list of "Unused messages" which are there only for your convenience so that you may use the text for the new translations if necessary. You can freely delete any unused messages.
Have a look at Notes for Translators. The explanation of using mini-gettext in code follows.
The simple syntax: A string becomes language string by enclosing into
It is better to create long strings than to concatenate short ones, because translators may easier understand the meaning.
The parametrized syntax: You must not use variables in language strings. But
you can use parameters
%1,%2,... with the syntax of
_m("... %1 ... %3 ... %2", array ($param1,$param2,$param3)), e.g.
_m("Click on %1 to get more help.", array ($url))or
_m("Error %1 in file %2 on line %3", array ($err,$file,$line)).
Always use the
array() even when using only one parameter
To update language files, use
xmgettext(). Call it by the
script. Have a look on particular settings in the script. You need to provide
read-write access for PHP to language files in order to update them. Copy
them into another directory (I used
../php_rw/lang, i.e. not
a subdir of the AA installation), set permissions, run
and copy the updated files back. A side remark: If you don't like this
overhead, just remember which overhead it took to create and copy all the
L_ language constants to new_news_lang.php3 ...
One more thing to take care of is the run-time switching between languages. If you fill in some include file a global variable with translated strings and than change language, it will remain in the old language. You must create a function returning the variable to avoid this.
Hope you will like my mgettext solution,
Last Edit: Aug 17 2011
<aafaq id=1691> ~ToDo: 1691 Language files with Mini Gettext </aafaq>
This FAQ interface was developed by Jason at Commons.ca
ActionApps is a free software content management system initiated by
the Association for Progressive Communications (APC)
APC - Internet and ICTs for social justice and development