[Vtigercrm-developers] A translation question (i18n)

Kristóf KOVÁCS kristof.kovacs at onlineprojects.hu
Mon Nov 24 06:36:28 PST 2008


Hello Tigers,
I was talking with Dávid of CafeOpen about vTiger translations, and there is
one issue which my team often faces with, and this is word order. Let me
illustrate it with an example (using German instead of Hungarian to make it
more clear, but the concept is the same).

For example, in ActivityEditView.tpl there is the following code:

<input title="{$APP.LBL_ADD_NEW} {$APP.Contact}" .....

And this shows a button called "Add Contact". It seems all well since
"$APP.LBL_ADD_NEW" is "Add" and "$APP.Contact" is "Contact".

But "Add Contact" in German is "Kontakt hinzufügen" (notice that the words
are in a different order). Now we have a problem since "{$APP.LBL_ADD_NEW}
{$APP.Contact}" can not be forced to display this, and saying "hinzufügen
Kontakt" does not sound quite right (it sounds very bad indeed).

Translation quirks can circumvent some of such problems (one could write
"Neue Contact"), but often these strings are reused at other parts of the
code, and fixing it in one place often destroys grammar at other places.

One idea would be to use printf()-like format strings to correct such
issues, even if it may require an introduction of a now Smarty function. I'm
thinking along the lines of something like this:

{a_smarty_printf_function
$APP.ADD_NEW_SOMETHING_FORMATSTRING, $APP.LBL_ADD_NEW, $APP.Contact}

Then, in english, the .lang file would read:
[...]
'LBL_ADD_NEW' = 'Add',
'Contact' => 'Contact',
'ADD_NEW_SOMETHING_FORMATSTRING' => "'%s %s", // Very simple format string,
no surprise here
[...]

And in german, it would be:
[...]
'LBL_ADD_NEW' = 'Hinzufügen',
'Contact' => 'Kontakt',
'ADD_NEW_SOMETHING_FORMATSTRING' => "'%2$s %1$s", // Notice how I used "1$"
and "2$" to access arguments in different order
[...]

I don't feel it elegant enough (but more elegant than the original), so
comments, suggestions, ideas, better solutions are very much welcome. Please
all brainstorm this ever the next coffee. :o)

Kristóf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20081124/3895a7df/attachment-0003.html 


More information about the vtigercrm-developers mailing list