On Mon, 23 Nov 2009 12:42:43 +0000
Hugo Monteiro <[email protected]> wrote:
> Hello all,
>
Hallo Hugo,
> I believe it would be a good thing (tm) to change the language dirs into
> their respective locale names, such as en_US, de_DE, fr_FR, etc.
> I'm predicting that, not far from now, there will be submissions of
> different language variations and it's my opinion that they all should
> be well accommodated.
>
> Any thoughts on this matter?
>
yes. We don't do anything. Not because I think it is not needed but because the
quick and dirty code I added for making the language detection already has what
you are looking for (you should know me by now. I always aim to make things as
flexible as possible but not more flexible then needed):
------------------
# Determine if templates are available for the current
# HTTP_ACCEPT_LANGUAGE (see RFC 4646 for more info).
my $langlist = lc($ENV{'HTTP_ACCEPT_LANGUAGE'})||'';
my $langpat = qr'[a-zA-Z]{1,8}(\-[a-zA-Z]{1,8})?';
my $qvalpat = qr'(0(\.\d{0,3})?)|(1(\.0{0,3})?)';
my $q = -1.0;
my $templates = '';
for my $langpref (split /,\s*/, $langlist) {
$langpref =~ /^([^;]+)(;q=)?(.*)?/;
my $lang = $1 || '';
my $qval = $3 || 1.0;
my $langcode = '';
if ($lang =~ /^($langpat)|(x\-$langpat)|\*$/ && $qval =~ /^($qvalpat)$/) {
if ($q lt $qval) {
$lang =~ s/^x\-//;
if ($lang =~ /^(.*)\-.+$/) {
$langcode = $1;
}
if ($lang ne '' && $lang ne '*' && -e $CONFIG{'TEMPLATES'} . '/' . $lang
. '/nav_performance.html') {
$q = $qval;
$templates = $CONFIG{'TEMPLATES'} . '/' . $lang;
} elsif ($langcode ne '' && -e $CONFIG{'TEMPLATES'} . '/' . $langcode .
'/nav_performance.html') {
$q = $qval;
$templates = $CONFIG{'TEMPLATES'} . '/' . $langcode;
}
}
}
}
if ($templates ne '') {
$CONFIG{'TEMPLATES'} = $templates;
}
------------------
See the part with $lang and the other with $langcode? So the check is as this:
en_US:
1) check for <TEMPLATE DIR>/en_us/nav_performance.html [found=use it,not
found=continue checking]
2) check for <TEMPLATE DIR>/en/nav_performance.html [found=use it,not
found=continue checking]
de_DE:
1) check for <TEMPLATE DIR>/de_de/nav_performance.html [found=use it,not
found=continue checking]
2) check for <TEMPLATE DIR>/de/nav_performance.html [found=use it,not
found=continue checking]
fr_FR:
1) check for <TEMPLATE DIR>/fr_fr/nav_performance.html [found=use it,not
found=continue checking]
2) check for <TEMPLATE DIR>/fr/nav_performance.html [found=use it,not
found=continue checking]
For simplicity I added the translations currently available in the repo only
with they language code (the characters before the "-") but the code is
prepared to handle anything. Even things like en_US, en_GB, whatever... and
nothing in the current code needs to be changed for handling that :)
It's nice to have a easy structue on the language directories following the
principle that the more verbose the request is the higher their weight is. So
if for example we would have this here:
./fr-ca/.....
./fr-ch/.....
./fr-be/....
./fr/....
And now someone comes with fr-mc then it's nice to know that the user will at
least see a French interface since he/she will fall back to ./fr/... because
there is no fr-mc but at least there is a fr.
> Regards,
>
Kind Regards from Switzerland,
> Hugo Monteiro.
>
Stevan Bajić
> --
> ci.fct.unl.pt:~# cat .signature
>
> Hugo Monteiro
> Email : [email protected]
> Telefone : +351 212948300 Ext.15307
> Web : http://hmonteiro.net
>
> Centro de Informática
> Faculdade de Ciências e Tecnologia da
> Universidade Nova de Lisboa
> Quinta da Torre 2829-516 Caparica Portugal
> Telefone: +351 212948596 Fax: +351 212948548
> www.ci.fct.unl.pt [email protected]
>
> ci.fct.unl.pt:~# _
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Dspam-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/dspam-devel
>
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Dspam-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dspam-devel