[Davical-dev] Internationalisation-Patch

Matthias Mohr Matthias at Mohrenclan.de
Tue Oct 27 01:38:43 NZDT 2009


Hi,

>   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 now created a patch to awl-0.38 (only User.php) and DAViCal-0.9.7.6 which 
does the above for all places where the given format string contains parameters.
The output of that strings is in page-header.php; therefore I modified that 
place to respects such message arrays which split format and parameters and 
only translate the format strings (and put it together with its parameters 
afterwards).

The patch also removes all unnecessary sprintf where no parameters are given...

One additional note:
I suggest, that all format strings with parameters which shall be translated
   should change the format, so that it's possible to change the order of the
   parameters in a translation (e.g. flip two parameters).
In PHP this works as follows:
instead of a format string
    'host=%s, user=%s, something else %s, %d'
you'll write
    'host=%1$s, user=%2$s, something else %3$s, %4$d'
then you could write as translated string e.g.
    'Benutzer=%2$s, Rechner=%1$s, %4$d was anderes %3$s'
and therefore change the order of the parameter values for different languages...
Regarding the PHP manual this works since PHP 4.06; though I'm not sure if it 
works with gettext...
I didn't add this to the patches because it would change all existring strings 
with parameters --> they would have been translated again for all languages.

Maybe it would be a good time to change it for 0.9.8 where a lot strings 
changes anyway?

regards,
Matthias

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: davical-0.9.7.6_internationalisation.diff
URL: <http://lists.morphoss.com/pipermail/davical-dev/attachments/20091026/7106c859/attachment.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: awl-0.38_internationalisation.diff
URL: <http://lists.morphoss.com/pipermail/davical-dev/attachments/20091026/7106c859/attachment.asc>


More information about the Davical-dev mailing list