Thanks to Honza and Marek I have added a new multilingual feature to AA CVS.
This is a AA database driven gettext that allows to translate short
strings (with parameters) similiar to GNU gettext.
Nice about it is that it allows to edit translations in AA admin
interface and secondly that it can automatically add items for unknown
texts.
Quickstart:
* create a slice to hold the short texts
- fields:
# headline (required) and of type headline...... -- set the name to
the default language (e.g. EN)
# one field for each other language, set name to the language, eg. DE,
FR, ES
That was easy, now the complicated bit.
* In one of the 'early' views of your slice add this:
{mlx:addslice:(id of the slice you just created):(some text to identify
your MLXGetText domain):learn}
e.g. {mlx:addslice:3a0c44958b1c6ad697804cfdbccd8b09:{l}:IWPR Site:learn}
'early' means that this has to be parsed by AA before {_m gets first
used. It's probably worth creating an extra view just to make sure this
is the case. I have noticed that if it is in the same view but before
the first {_m it can still be parsed after the {_m. It will not work in
this case. You can use ?errcheck=1 to check for errors.
* You should be ready to start using {_m:bla} in views etc.
It goes like this: once you use {_m:some text} MLX will automatically
add an item to the slice. You can then edit the translations in AA
admin. MLX makes sure it doesnt get added twice or overwritten.
Using the MLX view parameter, MLXGetText will figure out which
translation is available and print it accordingly. So in a view that has
e.g. ?vid=11&set[11]=mlx-DE MLXGetText will automatically use the Geramn
translation from your translations slice if available.
Additional features:
MLXGetText supports unlimited number of parameters in strings. This goes
like:
{_m:Today's date is %1.%2.%3:5.11.2004}
will print (in EN)
Today's date is 5.11.2004
in DE it will print
Das heutige Datum ist 5.11.2004
As usual, MLX is untested and I would appreciate any feedback.
Have fun with it and again thanks to Honza who already programmed
something very similiar before and gave me all of his code and Marek for
discussing the idea with him in Cape Town.
mimo aka Michael
|