Hi Stefan,
Thanks for the details.  There is also GNU gettext for C (our agents).

I wonder how this would work with libraries we link to (postgresql, etc) where 
the error messages are generated from those libraries.   We also have text 
stored in the database, like in 1.2 we have license text saved in the database. 
 Would they need to be translated?

This seems like an excellent idea but it means we need developers to sign up to 
do the translations in time with releases. A single developer leading the way 
and doing the German text would be a good start.  ;-)

We could start putting text into .po files (after v 1.2) if you really want to 
do this.   What would you like?

Bob Gobeille


On Dec 23, 2009, at 2:15 AM, Stefan Schroeder wrote:

As requested by Robert I am going to sketch which changes would be required to 
make FOSSology i18N compliant:

The translated text is _not_ stored in the original PHP-source files. Rather, 
all translatable strings are marked for processing with gettext:

Thus the file:

<?php
echo 'hello world';
?>

Is patched to

<?php
require_once('i18n.php');
echo _('hello world');
?>

The _() is a function used by the gettext-library. Then the translatable 
strings are extracted and stored in a separate file (po-file).
In the po-file, which is setup for each supported language, the translated 
strings are added.


# this is messages.po in locale/de_DE/LC_MESSAGES


msgid "hello world"

msgstr "hallo welt"


For performance reasons, this file is converted into a binary form (mo-file), 
and stored in locale/de_DE/LC_MESSAGES
or similar.
When the php-file is now requested, there is a tiny php-script - which is added 
by inserting it plainly or
by using 'required_once', to identify the wanted locale-setting.

The lines to be added contain the gettext-specifics
// this is i18n.php
[some code to determine locale and encoding]
setlocale(LC_MESSAGES, $locale);
bindtextdomain($domain, './locale');
bind_textdomain_codeset($domain, $encoding);
textdomain($domain);
// end

You can browse the web for details using the keywords
gettext php

A merry christmas to all of you.
Yours Stefan Schroeder


<ATT00001..txt>

_______________________________________________
fossology mailing list
[email protected]
http://fossology.org/mailman/listinfo/fossology

Reply via email to