Announcement

  •  » Translations
  •  » Improve localization and internationalization

#1 2010-02-21 21:12:34

nicolas
Former Piwigo Team
2004-12-30
1232

Improve localization and internationalization

Hi all,

I started working on [Bugtracker] ticket 1451. The idea is to replace old hash arrays for translations by a standard way to manage localization : gettext.

Extract all strings was a big work but it's almost finish. I faced with a problem : we used to have strange and without meaning key for our string to translate like cat_inclu_part1_S, ACCESS_1,... That's a very bad practice.

I think the right way is to replace all that strange keys by their translation in english. There's no real problem because english is the main language we use.

The next step will be to install a web interface to help translators manage translations. I think about pootle but if you know or just discover a great tools that can be interesting tell us and I will test it.

Offline

 

#2 2010-02-21 21:23:39

tosca
Former Piwigo Team
Cévennes (France)
2006-09-23
567

Re: Improve localization and internationalization

There is one (or 2 ?) translating applications for TYPOlight I'm used to, but I can't compare them to any other.

Here are the links and screencopys:
Core translator
Extension translator


My galleries : Photos, Watercolours, Recipes

Offline

 

#3 2010-02-21 23:06:20

nicolas
Former Piwigo Team
2004-12-30
1232

Re: Improve localization and internationalization

Thanks Tosca but I think theses tools are related to typolight and not public ?

Offline

 

#4 2010-02-21 23:27:15

tosca
Former Piwigo Team
Cévennes (France)
2006-09-23
567

Re: Improve localization and internationalization

nicolas wrote:

Thanks Tosca but I think theses tools are related to typolight and not public ?

Here is a public link to the core translator where you might find some information.
I don't find any equivalent for the extension translator (I get redirected to the login page), but I don't think it is as good as the other one (from a translator point of view).


My galleries : Photos, Watercolours, Recipes

Offline

 

#5 2010-02-22 21:25:42

grum
Former Piwigo Team
Pantin
2007-09-10
1371

Re: Improve localization and internationalization

nicolas wrote:

I think the right way is to replace all that strange keys by their translation in english. There's no real problem because english is the main language we use.

If the key have to be changed ? grammar errors, wording, sentence building...
The "english key" have an English translation or the key is directly used ?


My pictures with Piwigo, of course !
[ www.grum.fr ]

Offline

 

#6 2010-02-22 22:32:28

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: Improve localization and internationalization

1) agree with nicolas that the language key should be the English value.

grum wrote:

If the key have to be changed ? grammar errors, wording, sentence building...
The "english key" have an English translation or the key is directly used ?

2) I also feel concerned about this problem. Last time we met, nicolas told that in a perfect world, the english.po file should not be required, I mean we should use directly the key when current language is English.

I really wonder how to manage this in the real life. How does tools like Pootle manage this kind of situation.

Offline

 

#7 2010-02-22 22:45:38

nicolas
Former Piwigo Team
2004-12-30
1232

Re: Improve localization and internationalization

plg wrote:

2) I also feel concerned about this problem. Last time we met, nicolas told that in a perfect world, the english.po file should not be required, I mean we should use directly the key when current language is English.

But we are not in a perfect world. :-(
So what is the solution ? I have to double check and explain you how it can work in real life.

As I told you, the modification in source to fix grammar errors, wording, sentence building is native with gettext. The real problem is for customization. Some of you don't like category and start using album. Of course they can modify english (the master template) but others languages won't work anymore.
One ugly solution would be to have a piwigo-language for master template/fallback (which is english in fact) and keep en_US to customization.

Offline

 

#8 2010-02-22 22:51:41

grum
Former Piwigo Team
Pantin
2007-09-10
1371

Re: Improve localization and internationalization

So, this kind of text have to be typed directly in the code.... o_O;

Code:

$lang['Subscribe to Piwigo Announcements Newsletter'] = 'Keep in touch with Piwigo project, subscribe to Piwigo Announcement Newsletter. You will receive emails when a new release is available (sometimes including a security bug fix, it\'s important to know and upgrade) and when major events happen to the project. Only a few emails a year.';

My pictures with Piwigo, of course !
[ www.grum.fr ]

Offline

 

#9 2010-02-22 23:16:05

nicolas
Former Piwigo Team
2004-12-30
1232

Re: Improve localization and internationalization

grum wrote:

So, this kind of text have to be typed directly in the code.... o_O;

Code:

$lang['Subscribe to Piwigo Announcements Newsletter'] = 'Keep in touch with Piwigo project, subscribe to Piwigo Announcement Newsletter. You will receive emails when a new release is available (sometimes including a security bug fix, it\'s important to know and upgrade) and when major events happen to the project. Only a few emails a year.';

I know. It's the limit between translations and severals sites ! If you have a magic solution, I want it !

Offline

 

#10 2010-02-22 23:45:36

grum
Former Piwigo Team
Pantin
2007-09-10
1371

Re: Improve localization and internationalization

Short phrases : the phrase is the key
Very long phrases (more than 30~40 char ?) : needs a short key and a translation in a .po file

Last edited by grum (2010-02-22 23:45:55)


My pictures with Piwigo, of course !
[ www.grum.fr ]

Offline

 

#11 2010-02-23 12:55:18

nicolas
Former Piwigo Team
2004-12-30
1232

Re: Improve localization and internationalization

grum wrote:

Short phrases : the phrase is the key
Very long phrases (more than 30~40 char ?) : needs a short key and a translation in a .po file

If I understand your proposition, you want a special language for fallback and you want to keep en_US language. What will be the key for long phrases ? I want to avoid key without meaning to make life of translator easier as possible.

Offline

 

#12 2010-02-26 14:04:42

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: Improve localization and internationalization

grum wrote:

Short phrases : the phrase is the key
Very long phrases (more than 30~40 char ?) : needs a short key and a translation in a .po file

I've searched the web about this issue. I found nothing.

I agree with grum that sometimes we just can't have the english value in the middle of the code. It's far too long. grum took the $lang['Subscribe to Piwigo Announcements Newsletter'] as an example. I wrote it in the code. I've been avoiding to use meaningless keywords as keys for years BUT in this specific case I've decided to have:

1) a key which is shorter than the string in English
2) a key that can be used as value (remember that current algorithm is : is the value is not available in current language, display the key)

In addition to this kind of long values, I would like to talk about the dark side of i18n, I'm talking about the HTML files:

Code:

[pierrick@vienna] ~/public_html/piwigo/dev/trunk/language/en_UK
$ find . -name "*.html"
./help.html
./about.html
./help/synchronize.html
./help/thumbnail.html
./help/notification_by_mail.html
./help/configuration.html
./help/cat_options.html
./help/permalinks.html
./help/advanced_feature.html
./help/user_list.html
./help/site_manager.html
./help/group_list.html
./help/history.html
./help/maintenance.html
./help/cat_perm.html
./help/cat_modify.html
./help/search.html
./help/cat_move.html
./help/extend_for_templates.html

I would like to avoid a double system for translation.

I'm sure the current way to display help is not perfect. For example, in a single page, we should display long tooltips on several question marks "?", instead of the current sytem "1 admin page = 1 single help popup". But anyway, we will have long sentences inside these tooltips. And we just can't have them as is in source code. Or else the PHP source code will become a mess.

My current state of mind: I agree with grum, if the string is too long (let's go to 80 chars, as we can have 120 chars in a PHP line), then we use a "degraded" string as key. But the key must be usable as displayed string anyway.

Now, let's see how it's done in another PHP application, I'll take WordPress because I know they're using gettext.

Offline

 

#13 2010-02-26 14:17:44

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: Improve localization and internationalization

plg wrote:

Now, let's see how it's done in another PHP application, I'll take WordPress because I know they're using gettext.

In Wordpress:

1) there seems to be no "shorter key", this makes the PHP code a bit messy in my opinion,
2) to get even longer descriptions, there is a link to there wiki.

I don't really like the way it's done. Messy for first bullet, and opposed to l10n for links to wiki. Well, it's fine to have a link to the right page on the wiki, but it mustn't be the only help. Wiki will certainly not be as translated as integrated help.

Offline

 

#14 2010-02-26 14:24:06

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: Improve localization and internationalization

In Dotclear, just like currently in Piwigo, they have locales/en/help/posts.html

tosca, how is managed in typolight? What's your opinion about having 1 process to translate labels (short strings) and another process to translate integrated help (long strings)?

Offline

 

#15 2010-02-26 15:31:36

tosca
Former Piwigo Team
Cévennes (France)
2006-09-23
567

Re: Improve localization and internationalization

plg wrote:

tosca, how is managed in typolight? What's your opinion about having 1 process to translate labels (short strings) and another process to translate integrated help (long strings)?

Though I have followed this thread from the beginning, I have not understood everything, far from it actually ;-)

I just had a look at the TL languages files. Here a some extracts :
- from the backend/language/en/default.php file

Code:

$GLOBALS['TL_LANG']['ERR']['general']        = 'An error occurred!';
$GLOBALS['TL_LANG']['ERR']['unique']         = 'Duplicate entry in field "%s"!';
$GLOBALS['TL_LANG']['ERR']['mandatory']      = 'Please fill in field "%s"!';
$GLOBALS['TL_LANG']['ERR']['minlength']      = 'Field "%s" has to be at least %d characters long!';
$GLOBALS['TL_LANG']['ERR']['digit']          = 'Please enter digits only!';
$GLOBALS['TL_LANG']['ERR']['prcnt']          = 'Please enter a percentage between 0 und 100!';
$GLOBALS['TL_LANG']['ERR']['alpha']          = 'Please enter alphabetic characters only!';
$GLOBALS['TL_LANG']['ERR']['alnum']          = 'Please enter alphanumeric characters only!';
$GLOBALS['TL_LANG']['ERR']['phone']          = 'Please enter a valid phone number!';
$GLOBALS['TL_LANG']['ERR']['extnd']          = 'For security reasons you can not use these characters (=<>&/()#) here!';
$GLOBALS['TL_LANG']['ERR']['email']          = 'Please enter a valid e-mail address!';
$GLOBALS['TL_LANG']['ERR']['url']            = 'Please enter a valid URL format and encode special characters!';
$GLOBALS['TL_LANG']['ERR']['date']           = 'Please enter the date as "%s"!';
$GLOBALS['TL_LANG']['ERR']['time']           = 'Please enter the time as "%s"!';
$GLOBALS['TL_LANG']['ERR']['dateTime']       = 'Please enter date and time as "%s"!';
$GLOBALS['TL_LANG']['ERR']['noSpace']        = 'Field "%s" must not contain any whitespace characters!';
$GLOBALS['TL_LANG']['ERR']['filesize']       = 'The maximum size for file uploads is %s kB!';
$GLOBALS['TL_LANG']['ERR']['filetype']       = 'File type "%s" is not allowed to be uploaded!';
$GLOBALS['TL_LANG']['ERR']['filepartial']    = 'File %s was only partially uploaded!';
$GLOBALS['TL_LANG']['ERR']['filewidth']      = 'File %s exceeds the maximum image width of %d pixels!';

- and the equivalent backend/language/fr/default.php file

Code:

$GLOBALS['TL_LANG']['ERR']['general'] = 'Une erreur est survenue !';
$GLOBALS['TL_LANG']['ERR']['unique'] = 'Doublon dans le champ "%s" !';
$GLOBALS['TL_LANG']['ERR']['mandatory'] = 'Veuillez remplir le champ "%s" !';
$GLOBALS['TL_LANG']['ERR']['minlength'] = 'Le champ "%s" doit posséder au moins %d caractères !';
$GLOBALS['TL_LANG']['ERR']['digit'] = 'Veuillez seulement saisir des chiffres !';
$GLOBALS['TL_LANG']['ERR']['prcnt'] = 'Veuillez saisir une valeur entre 0 et 100% !';
$GLOBALS['TL_LANG']['ERR']['alpha'] = 'Veuillez seulement saisir des caractères alphabétiques !';
$GLOBALS['TL_LANG']['ERR']['alnum'] = 'Veuillez seulement saisir des caractères alphanumériques !';
$GLOBALS['TL_LANG']['ERR']['phone'] = 'Veuillez saisir un numéro de téléphone valide !';
$GLOBALS['TL_LANG']['ERR']['extnd'] = 'Pour des raisons de sécurité n\'utilisez pas ces caractères (=&/()#) ici !';
$GLOBALS['TL_LANG']['ERR']['email'] = 'Veuillez saisir une adresse e-mail valide !';
$GLOBALS['TL_LANG']['ERR']['url'] = 'Veuillez saisir une URL valide et encodez les caractères spéciaux !';
$GLOBALS['TL_LANG']['ERR']['date'] = 'Veuillez saisir la date "%s" !';
$GLOBALS['TL_LANG']['ERR']['time'] = 'Veuillez saisir l\'heure "%s" !';
$GLOBALS['TL_LANG']['ERR']['dateTime'] = 'Veuillez saisir la date et l\'heure "%s" !';
$GLOBALS['TL_LANG']['ERR']['noSpace'] = 'Le champ "%s" ne doit pas contenir d\'espace !';
$GLOBALS['TL_LANG']['ERR']['filesize'] = 'La taille maximale pour l\'envoi de fichier est %s Ko !';
$GLOBALS['TL_LANG']['ERR']['filetype'] = 'Le fichier de type "%s" n\'est pas autorisé pour l\'envoi !';
$GLOBALS['TL_LANG']['ERR']['filepartial'] = 'Le fichier %s a été envoyé partiellement !';
$GLOBALS['TL_LANG']['ERR']['filewidth'] = 'L\'image %s dépasse la largeur maximale qui est de %d pixels !';

Another example, for the calendar module, shows a short label and a long one, that appears when hovering over the short one.
- from calendar/language/en/module.php

Code:

/**
 * Back end modules
 */
$GLOBALS['TL_LANG']['MOD']['calendar'] = array('Events', 'Manage events and display them in a calendar or event list.');


/**
 * Front end modules
 */
$GLOBALS['TL_LANG']['FMD']['events']          = 'Events';
$GLOBALS['TL_LANG']['FMD']['calendar']        = array('Calendar', 'adds a calendar to the page.');
$GLOBALS['TL_LANG']['FMD']['eventreader']     = array('Event reader', 'shows the details of an event.');
$GLOBALS['TL_LANG']['FMD']['eventlist']       = array('Event list', 'adds a list of events to the page.');

- and from calendar/language/fr/module.php

Code:

$GLOBALS['TL_LANG']['MOD']['calendar'] = array('Calendrier / Événements', 'Gérer les événements et les afficher dans un calendrier ou une liste d\'événements.');
$GLOBALS['TL_LANG']['FMD']['events'] = 'Calendrier / Événements';
$GLOBALS['TL_LANG']['FMD']['calendar'] = array('Calendrier', 'Ajoute un calendrier dans une page.');
$GLOBALS['TL_LANG']['FMD']['eventreader'] = array('Lecteur d\'événement', 'Affiche les détails d\'un événement.');
$GLOBALS['TL_LANG']['FMD']['eventlist'] = array('Liste d\'événements', 'Ajoute une liste d\'événements dans une page.');
$GLOBALS['TL_LANG']['FMD']['upcoming_events'] = array('Événements à venir', 'Ajoute une liste des événements à venir dans une page.');

So there seems to be a whole multi-dimensional array, that serves to every module, and is accessed by a short key (a one-word key, as it seems) plus some litteral related to the module, I think.
I'm not sure this will give you much help, but I can dig a bit more if you have more or less precise questions.


My galleries : Photos, Watercolours, Recipes

Offline

 
  •  » Translations
  •  » Improve localization and internationalization

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact