Mailing List Archive

Internationalization
Hi Andrew,

I've currently found two places, where either the call to "translate" is
missing or the call to i18n is IMHO wrong.

1.) in DAViCalUser.php, there's a call to translate missing and therefore
"Delete User" does not get translated;
at line 93 you wrote:
------------------------------------------------------------------------
$html .= sprintf('<a class="fsubmit"
href="%s/usr.php?user_no=%s&action=delete_user">Delete User</a>',
$c->base_url, $this->user_no );
------------------------------------------------------------------------
and I write:
------------------------------------------------------------------------
$html .= sprintf('<a class="fsubmit"
href="%s/usr.php?user_no=%s&action=delete_user">%s</a>', $c->base_url,
$this->user_no, translate('Delete User') );
------------------------------------------------------------------------

2.) in drivers_ldap.php in method sync_LDAP (and other methods as well)
are a lot of places where you call i18n to a sprintf format string which
then gets added to the $c->messages array.
I assume that later another method prints out the strings from the messages
array and sents the strings through the translate function.
But this will not work - the gettext library does only know about the
format string and not the string with extracted variables.
So I think all that places in drivers_ldap.php should be changed to directly
call "translate" instead of "i18n" to make it work.
Another possibility would be to distinguish between format strings and
parameters and store them separately in a multi dimensional array
Like follows:
$c->messages[] = array( 'format' -> i18n("text with params %s, %s"),

'params' -> array( $param1, $param2 ) );
After that you could send the format string through the translate function
and put the whole string together afterwards...

I hope the above lines are understandable...

regards,
Matthias
Internationalization [ In reply to ]
On Mon, 2009-10-26 at 08:37 +0100, Matthias Mohr wrote:
> Hi Andrew,
>
> I've currently found two places, where either the call to "translate" is
> missing or the call to i18n is IMHO wrong.
>
> 1.) in DAViCalUser.php, there's a call to translate missing and therefore
> "Delete User" does not get translated;
> at line 93 you wrote:
> ------------------------------------------------------------------------
> $html .= sprintf('<a class="fsubmit"
> href="%s/usr.php?user_no=%s&action=delete_user">Delete User</a>',
> $c->base_url, $this->user_no );
> ------------------------------------------------------------------------
> and I write:
> ------------------------------------------------------------------------
> $html .= sprintf('<a class="fsubmit"
> href="%s/usr.php?user_no=%s&action=delete_user">%s</a>', $c->base_url,
> $this->user_no, translate('Delete User') );
> ------------------------------------------------------------------------

Thanks - fixed now.


> 2.) in drivers_ldap.php in method sync_LDAP (and other methods as well)
> are a lot of places where you call i18n to a sprintf format string which
> then gets added to the $c->messages array.

I didn't write drivers_ldap (it's contributed code), so this probably
reflects a failure of understanding of how the translation stuff worked
from the original author.


> I assume that later another method prints out the strings from the messages
> array and sents the strings through the translate function.
> But this will not work - the gettext library does only know about the
> format string and not the string with extracted variables.
> So I think all that places in drivers_ldap.php should be changed to directly
> call "translate" instead of "i18n" to make it work.
> Another possibility would be to distinguish between format strings and
> parameters and store them separately in a multi dimensional array
> Like follows:
> $c->messages[] = array( 'format' -> i18n("text with params %s, %s"),
>
> 'params' -> array( $param1, $param2 ) );
> After that you could send the format string through the translate function
> and put the whole string together afterwards...
>
> I hope the above lines are understandable...

The general consensus is that translations don't work with format
strings, and you have to do the translation on the formatted string.
While they might work for languages from the same family like English &
Deutsch, they fall down for more unusual (to us) languages where stuff
happens that sounds strange to us, like:

* quantity related suffixes vary depending to strange rules
* word ordering is completely very different
* many more situations that I know little of the particulars of

My wife was explaining to me about how everything that you can count
varies the names of numbers in Japanese according to situations like
whether you are counting things with or without a backbone, people,
bottles, months, days and so on. For the curious, here's a link:

http://www.learnjapanesefree.com/counters-in-japanese.html

This kind of thing makes it very difficult indeed to translate using
format strings :-)


Probably what this means is that some of the UI parts of drivers_ldap
need to be reviewed / rewritten with an eye to minimising constructed
strings in order to make it more straightforwardly translatable.

Cheers,
Andrew.

------------------------------------------------------------------------
andrew (AT) morphoss (DOT) com +64(272)DEBIAN
Suspicion always haunts the guilty mind.
-- Wm. Shakespeare

------------------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.morphoss.com/pipermail/davical-dev/attachments/20091027/c5deef0c/attachment.pgp>