Przeglądaj źródła

language names are upper case internally

Christoph Berg 21 lat temu
rodzic
commit
ca7e05688a
4 zmienionych plików z 14 dodań i 8 usunięć
  1. 2 1
      docs/pisg-doc.xml
  2. 2 2
      lang.txt
  3. 7 2
      modules/Pisg.pm
  4. 3 3
      modules/Pisg/HTMLGenerator.pm

+ 2 - 1
docs/pisg-doc.xml

@@ -842,10 +842,11 @@
     IS    (Icelandic),
     IT    (Italian),
     NL    (Dutch),
+    NL_BE (Flemish),
     NO    (Norwegian),
     PL    (Polish),
     PT    (Portuguese),
-    PT-BR (Portuguese/Brazil),
+    PT_BR (Portuguese/Brazil),
     RO    (Romanian),
     RU    (Russian),
     SE    (Swedish),

+ 2 - 2
lang.txt

@@ -10,7 +10,7 @@
 # (DE) German - Christoph Berg <cb@df7cb.de>
 # (NO) Norwegian - Andreas Blaafladt <andreabl@login1.powertech.no>
 # (PT) Portuguese - MrWho <mrwho@softhome.net>
-# (PT-BR) Portuguese/BR(Brazil) - francisco lopes <falmp@terra.com.br>
+# (PT_BR) Portuguese/BR(Brazil) - francisco lopes <falmp@terra.com.br>
 # (DA) Danish - Morten Brix Pedersen <morten at wtf dot dk>
 # (FR) French - Molator <molator@ifrance.com>
 # (ES) Spanish - Sheuron Azxe <xeron@cfutura.com>
@@ -2705,7 +2705,7 @@ mailto = "Mail til"
 </lang>
 
 ### Portuguese/Brazil
-<lang name="PT-BR" charset="iso-8859-1">
+<lang name="PT_BR" charset="iso-8859-1">
 action1 = "<b>[:nick]</b> sempre nos deixou por dentro do que [:ele:ela:] estava fazendo: <b>[:actions]</b> actions!"
 action2 = "<b>[:nick]</b> também nos contou sobre o que se passava com <b>[:actions]</b> actions."
 action3 = "Não houve actions no [:channel]!"

+ 7 - 2
modules/Pisg.pm

@@ -102,7 +102,7 @@ sub get_default_config_settings
         defaultpic => '',
         logdir => [],
         nfiles => 0,
-        lang => 'en',
+        lang => 'EN',
         langfile => 'lang.txt',
         cssdir => 'layout/',
         colorscheme => 'default',
@@ -230,7 +230,7 @@ sub get_language_templates
 
         if ($line =~ /<lang name=\"([^"]+)\"(?: charset=\"(.*)\")?>/i) {
             # Found start tag, setting the current language
-            my $current_lang = lc($1);
+            my $current_lang = uc($1);
             $self->{tmps}->{$current_lang}{lang_charset} = lc($2);
 
             while (<FILE>) {
@@ -406,6 +406,9 @@ sub init_pisg
     }
     $self->{cfg}->{timestamp} = $timestamp;
 
+    $self->{cfg}->{lang} = uc $self->{cfg}->{lang};
+    $self->{cfg}->{lang} =~ s/-/_/g; # PT_BR was called PT-BR before
+
     # convert wordlists
     $self->{cfg}->{foulwords} = wordlist_regexp($self->{cfg}->{foulwords}, $self->{cfg}->{regexpaliases});
     $self->{cfg}->{ignorewords} = wordlist_regexp($self->{cfg}->{ignorewords}, $self->{cfg}->{regexpaliases});
@@ -428,6 +431,8 @@ sub init_pisg
 
     unless ($self->{cfg}->{silent}) {
         print "Statistics for channel $self->{cfg}->{channel} \@ $self->{cfg}->{network} by $self->{cfg}->{maintainer}\n\n";
+        die sprintf "No such language: %s\n", $self->{cfg}->{lang}
+            unless $self->{tmps}->{$self->{cfg}->{lang}};
         print "Using language template: $self->{cfg}->{lang}\n\n" if $self->{cfg}->{lang} ne 'EN';
     }
 }

+ 3 - 3
modules/Pisg/HTMLGenerator.pm

@@ -27,7 +27,7 @@ sub new
     require Pisg::Common;
     Pisg::Common->import();
 
-    my $lang_charset = $self->{tmps}->{lc($self->{cfg}->{lang})}{lang_charset};
+    my $lang_charset = $self->{tmps}->{$self->{cfg}->{lang}}{lang_charset};
     if($lang_charset and $lang_charset ne $self->{cfg}->{charset}) {
         if($have_iconv) {
             # convert from template charset to our
@@ -1612,10 +1612,10 @@ sub _template_text
 
     my $text;
 
-    unless ($text = $self->{tmps}->{lc($self->{cfg}->{lang})}{$template}) {
+    unless ($text = $self->{tmps}->{$self->{cfg}->{lang}}{$template}) {
         # Fall back to English if the language template doesn't exist
 
-        if ($text = $self->{tmps}->{en}{$template}) {
+        if ($text = $self->{tmps}->{EN}{$template}) {
             print "Note: No translation in '$self->{cfg}->{lang}' for '$template' - falling back to English.\n"
                 unless ($self->{cfg}->{silent});
         } else {