Objet : Pour les administrateurs de serveurs de listes utilisant le logiciel Sympa
Archives de la liste
[sympa-fr] Re: Re: Sympa 5.3 & OpenBSD 4.1: setlocale
- From: Olivier Salaün <adresse@cachée>
- To: Jean-Gérard Pailloncy <adresse@cachée>
- Cc: adresse@cachée
- Subject: [sympa-fr] Re: Re: Sympa 5.3 & OpenBSD 4.1: setlocale
- Date: Tue, 07 Aug 2007 16:01:55 +0200
Bonjour,
Ce problème de locales sous FreeBSD/OpenBSD devrait être réglé par le patch ci-joint qui permet d'utiliser utf-8 au lieu des encodages ISO-*. En effet, depuis sa version 5.3, Sympa généralise l'utilisation de UTF-8.
Jean-Gérard Pailloncy a écrit :
Sympa utilise gettext (et donc nécessite des locales correctementJe n'ai pas trouvé dans les archives beaucoup de références à OpenBSD.
installées) depuis sa version 4.2b.3 (aout 2004).
Mais je pense que vous prenez les problèmes à l'envers : d'autre
utilisateurs utilisent des versions récentes de Sympa sur OpenBSD.
Je les laisse répondre...
En continuant mes investigations:
J'ai modifié Language.pm pour loguer la recherche de locale:
foreach my $type (&POSIX::LC_ALL, &POSIX::LC_TIME) {
my $success;
foreach my $try ($locale.'.'.$locale2charset{$locale},
$locale.'.'.uc($locale2charset{$locale}),
$locale_dashless,
$locale,
$lang,
'fr_FR.ISO8859-1',
'C') {
&do_log('err', "$type - $try\n");
if (&setlocale($type, $try)) {
$success = 1;
last;
}
}
Et voici le résultat (extrait):
Jun 7 02:58:37 list sympa[16743]: Language::SetLang() 0 - fr_FR.iso-8859-1
Jun 7 02:58:37 list sympa[16743]: Language::SetLang() 5 - fr_FR.iso-8859-1
Jun 7 02:58:37 list sympa[16743]: Language::SetLang() 5 - fr_FR.ISO-8859-1
Jun 7 02:58:37 list sympa[16743]: Language::SetLang() 5 - fr_FR.iso88591
Jun 7 02:58:37 list sympa[16743]: Language::SetLang() 5 - fr_FR
Jun 7 02:58:37 list sympa[16743]: Language::SetLang() 5 - fr
Jun 7 02:58:37 list sympa[16743]: Language::SetLang() 5 - fr_FR.ISO8859-1
Jun 7 02:58:37 list sympa[16743]: Language::SetLang() 5 - C
J'ai ajouté "fr_FR.ISO8859-1" car dans /usr/share/locale il y avait un
dossier portant ce nom, mais cela semble inutile. Seule 'C' marche.
Index: src/Language.pm
===================================================================
--- src/Language.pm (revision 4514)
+++ src/Language.pm (working copy)
@@ -78,34 +78,6 @@
'tr' => 'tr_TR',
'tw' => 'zh_TW');
-## Used to define encoding for service messages sent by Sympa
-## Also used to perform setlocale on FreeBSD / Solaris
-my %locale2charset = ('bg_BG' => 'utf-8',
- 'cs_CZ' => 'utf-8',
- 'de_DE' => 'iso-8859-1',
- 'el_GR' => 'utf-8',
- 'en_US' => 'utf-8',
- 'es_ES' => 'iso-8859-1',
- 'et_EE' => 'iso-8859-4',
- 'fi_FI' => 'iso-8859-1',
- 'fr_FR' => 'iso-8859-1',
- 'hu_HU' => 'iso-8859-2',
- 'it_IT' => 'iso-8859-1',
- 'ja_JP' => 'eucJP', # Case sensitive.
- 'nb_NO' => 'utf-8',
- 'nl_NL' => 'iso-8859-1',
- 'oc_FR' => 'iso-8859-1',
- 'pl_PL' => 'iso-8859-2',
- 'pt_BR' => 'utf-8',
- 'pt_PT' => 'iso-8859-1',
- 'ro_RO' => 'iso-8859-2',
- 'ru_RU' => 'utf-8',
- 'sv_SE' => 'utf-8',
- 'tr_TR' => 'utf-8',
- 'zh_CN' => 'utf-8',
- 'zh_TW' => 'big5',
- );
-
## We use different catalog/textdomains depending on the template that requests translations
my %template2textdomain = ('help_admin.tt2' => 'web_help',
'help_arc.tt2' => 'web_help',
@@ -178,12 +150,12 @@
}
## Set Locale::Messages context
- my $locale_dashless = $locale.'.'.$locale2charset{$locale};
+ my $locale_dashless = $locale.'.utf-8';
$locale_dashless =~ s/-//g;
foreach my $type (&POSIX::LC_ALL, &POSIX::LC_TIME) {
my $success;
- foreach my $try ($locale.'.'.$locale2charset{$locale},
- $locale.'.'.uc($locale2charset{$locale}), ## UpperCase required for FreeBSD
+ foreach my $try ($locale.'.utf-8',
+ $locale.'.UTF-8', ## UpperCase required for FreeBSD
$locale_dashless, ## Required on HPUX
$locale,
$lang
@@ -210,7 +182,7 @@
$current_lang = $lang;
$current_locale = $locale;
- $current_charset = $locale2charset{$locale};
+ $current_charset = 'utf-8';
return $locale;
}#SetLang
Index: po/check_locales.pl
===================================================================
--- po/check_locales.pl (revision 4520)
+++ po/check_locales.pl (working copy)
@@ -28,12 +28,23 @@
my (@supported, @not_supported);
-foreach my $l (@locales) {
- if (setlocale(&POSIX::LC_ALL, $l)) {
- push @supported, $l;
- }else {
- push @not_supported, $l;
+foreach my $loc (@locales) {
+ my $locale_dashless = $loc.'.utf-8'; $locale_dashless =~ s/-//g;
+ my $lang = substr($loc, 0, 2);
+ my $success;
+ foreach my $try ($loc.'.utf-8',
+ $loc.'.UTF-8', ## UpperCase required for FreeBSD
+ $locale_dashless, ## Required on HPUX
+ $loc,
+ $lang) {
+ if (setlocale(&POSIX::LC_ALL, $try)) {
+ push @supported, $loc;
+ $success = 1;
+ last;
+ }
}
+ push @not_supported, $loc unless ($success);
+
}
if ($#supported == -1) {
@@ -49,7 +60,7 @@
}elsif ($#not_supported > -1){
printf "#############################################################################################################\n";
printf "## IMPORTANT : Sympa is not able to use all supported locales because they are not properly configured on this server\n";
- printf "## Herer is a list on NOT supported locales :\n";
+ printf "## Herer is a list of NOT supported locales :\n";
printf "## %s\n", join(' ', @not_supported);
printf "## On Debian you should run the following command : dpkg-reconfigure locales\n";
printf "## On others systems, check /etc/locale.gen or /etc/sysconfig/i18n files\n";
- [sympa-fr] Re: Re: Sympa 5.3 & OpenBSD 4.1: setlocale, Olivier Salaün, 07/08/2007
Archives gérées par MHonArc 2.6.19+.