From: Nyloth <ny...@ti...> - 2008-03-24 17:18:19
|
Hi Sylvie and others, For me, proposition 1) is bad and not clean. IMO, It is not well-designed and will only work to generate HTML. We may want to generate other formats using our translation system. Between those solutions, my preference clearely goes to the proposition 2). We may even have some sort of automated stuff for this. For example, if we have {tr type=abbrev}Locked{/tr}, we could first check if we have an abbrev translation and, if not, generate a string using a simple algorithm, such as: L. (first letter + dot), Lock. (50% + dot), Lckd. (without vowel), Lock... (first 4 letters with '...'), ... Same for the translation of "%d online users". You're right, the tests made on $nb will depend on the language. And all this stuff will pollute and complicate the template. If we really want to handle this kind of stuff, I propose to look at another translation system (what is done for other software ?). Using our $lang array, I would prefer to keep simple and clear things in templates like "%d online users", but be able to choose, for each lang file, either a string as the tranlation as used now for everything ("%d online users" => "%d utilisateurs connectés") or an array like this: "%d online users" => array( "0" => "aucun utilisateur connecté", "1" => "un utilisateur connecté", "2" => "%d utilisateurs connectés" ) This may work for most language. In french, we only have singular (for %d == 1) and plural (for %d >= 2). We can add something for the zero value too. And if the translator didn't used this array form, but just a string, simply use the string. In other languages like Japanese, Polish or some others, it's not so simple. For example, for Polish and Russian, we will have to deal with different translations when %d varies. I found an interesting page where Trolltech details what they have done for the Qt library (which is used by KDE projects), here: http://doc.trolltech.com/qq/qq19-plurals.html Refering to this article, maybe could we have something better with: "%d online users" => array( "singular" => "aucun utilisateur connecté", "plural" => "un utilisateur connecté", "paucal" => "%d utilisateurs connectés" ) And, like them, define the rule for each language hardcoded in our translation system. About weither to have, or not, a separate file for abbrevations, I prefer a separate file, using the same english strings as the array keys. It will imply to modify our translations functions to check if there is an abbrev.php file and, if so, check if there is a translation for the string we are looking for, and then fallback to the language.php and custom.php files (eventually using a simple algorithm as described above to reduce the string in an automated way). Cheers, Nyloth. On Monday 24 March 2008 14:05:23 Sylvie Greverend wrote: > So , with luciash consideration, I tried to reformulate a little bit > > 1)do we choose an html comment in the string > So in language .php > "l<!--abbrev locked-->"=> > "%d online users<!--{if $nb <= 1}0{elseif $nb <=4}2{/if}-->"=> > > Nothing to do for English > To avoid extra work for translators, the tra function must look for the > string without comment if translation not found > But - I am sure about the convention about the number ... as it depends > on the language > > 2)a param > {tr type=abbrev}locked{/tr} > {tr type=abbrev_1}locked{/tr} > {tr type=$nb}%d online users{/tr} > > and an extra file ? or at the end of language.php ? > in English > $type_abbrev_1 = array("locked"=>"l"); > $type_abbrev = array("locked"=>"lck"); > $type_1 = array("%d online users"=>"1 online user"); > > In French > $type_abbrev_1 = array("verrouillé"=>"v"); > $type_abbrev = array("verrouillé"=>"ver"); > $type_1 = array("%d utilisateurs en ligne"=>"1 utilisateur en ligne"); > $type_0 = array("%d utilisateurs en ligne"=>"0 utilisateur en ligne"); > > In the tra function, we add an additional step, look in the traduction > is in the array $type_param. > > --------------- > Which one? |