Changeset 14959
- Timestamp:
- 06/11/12 08:47:19 (11 months ago)
- File:
-
- 1 edited
-
trunk/core/lib/Foswiki/I18N.pm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/core/lib/Foswiki/I18N.pm
r13286 r14959 53 53 $tag =~ s/[^a-z-]//g; 54 54 return $tag; 55 } 56 57 sub _loadLexicon { 58 my ( $lang, $dir ) = @_; 59 60 $dir ||= $Foswiki::cfg{LocalesDir}; 61 62 my $langFile = "$dir/$lang.po"; 63 64 #print STDERR "langFile=$langFile\n"; 65 66 # Use the compressed version if it exists 67 if ( $langFile =~ m/^(.*)\.po$/ 68 && -f "$1.mo" ) 69 { 70 $langFile = "$1.mo"; 71 } 72 if ( -f $langFile ) { 73 unless ( 74 eval { 75 Locale::Maketext::Lexicon->import( 76 { $lang => [ Gettext => $langFile ] } ); 77 1; 78 } 79 ) 80 { 81 push( @initErrors, "I18N - Error loading language $lang: $@\n" ); 82 } 83 } 55 84 } 56 85 … … 99 128 ); 100 129 } 130 131 opendir( my $dh, "$Foswiki::cfg{LocalesDir}/" ) || next; 132 my @subDirs = 133 grep { !/^\./ && -d "$Foswiki::cfg{LocalesDir}/$_" } readdir $dh; 134 closedir $dh; 135 101 136 foreach my $lang (@languages) { 102 my $langFile = "$Foswiki::cfg{LocalesDir}/$lang.po"; 103 104 # Use the compressed version if it exists 105 if ( $langFile =~ m/^(.*)\.po$/ 106 && -f "$1.mo" ) 107 { 108 $langFile = "$1.mo"; 109 } 110 if ( -f $langFile ) { 111 unless ( 112 eval { 113 Locale::Maketext::Lexicon->import( 114 { $lang => [ Gettext => $langFile ] } ); 115 1; 116 } 117 ) 118 { 119 push( @initErrors, 120 "I18N - Error loading language $lang: $@\n" ); 121 } 122 } 123 else { 124 push( @initErrors, 125 "I18N - Ignoring enabled language $lang as $langFile does not exist.\n" 126 ); 127 } 137 _loadLexicon($lang); 138 _loadLexicon( $lang, "$Foswiki::cfg{LocalesDir}/$_" ) foreach @subDirs; 128 139 } 129 140 }
Note: See TracChangeset
for help on using the changeset viewer.
