Sylvain Beucler <[EMAIL PROTECTED]> wrote:
> Hi,
>
> First, thanks for the changes :)
>
> Can you explain a bit more the work in frontend/php/include/i18n.php?
The changes aimed to make Savane determine automatically whether a requested
translation is available and to provide for a flexible algorithm of
selecting a matching translation.
Currently, when adding a new localization to Savane, one has to modify
i18n.php by adding a set of `language=>localization' correspondencies to
$supportedLanguages array. Usually several entries are added to the
array, for each territory where the language is spoken, plus a general,
territory-independent entry. E.g., for German:
...
"de" => "DE.UTF-8",
"de_DE" => "DE.UTF-8",
...
This scheme is rather weak. First, it does not fully describe the
localization: in the above example, at least de_AT and de_CH are
missing, so a person which has any of them set in his browser
preferences will never get the German translation. Secondly, given
sufficient number of available localizations, this array will grow very
large and difficult to maintain.
The proposed solution uses a single array which defines a `default'
country code (ISO 3166) for each language code from ISO 639 (the notion
of the `default code' is described in the comment before the array
definition). This array has about 180 entries and will hardly change in
the foreseeable future, so there is little maintenance burden. When
analyzing browser preferences, if a qualified locale code is found, it
is processed as usual, i.e. Savane tries to find an exact matching
localization. If an unqualified language code is found (e.g. 'de', or
'fr' ...), its default territory is looked up and appended to it to get
the fully qualified locale name, useful for verifying whether the
localization is actually available.
I future I plan to add further improvements that should allow to pick
the closest translation when no strict match is found. For example, if
the requestor browser specifies a preference for 'fr_BE', and we do not
currently have this localization, it is always reasonable to return
`fr_FR' (available for Savane), instead of the default `en_US'.
Notice also, that there is now no need to modify i18n.php when adding a new
localization. It suffices to copy the $lang.po file to savane/po.
Regards,
Sergey
_______________________________________________
Savane-dev mailing list
[email protected]
https://mail.gna.org/listinfo/savane-dev