Item13399: Display error in trunk/utf8 branch... easy fixes.
Priority: Normal
Current State: Closed
Released In: n/a
Target Release: n/a
Applies To: Engine
Component: Utf8Branch
Branches: master
How to reproduce
- Install the utf8 branch
- run it with lighttpd.pl
- configure
- enable UI-internationalisation
- enable some languages like Czech, Russian and such
- save an go to wiki
- Errors like in the attached screenshots
Source of problems
The maketext lexicon load has a parameter
_decode
, cite from the docs:
_decode
If set to a true value, source entries will be converted into utf8-strings.
Also, the language cache is stored as utf8 encoded file, so at the read need decode it.
Needed changes
--- cdotutf/foswiki/core/lib/Foswiki/I18N.pm 2015-05-09 07:24:42.000000000 +0200
+++ cdotutfdev/foswiki/core/lib/Foswiki/I18N.pm 2015-05-09 10:33:30.000000000 +0200
@@ -80,7 +80,7 @@
unless (
eval {
Locale::Maketext::Lexicon->import(
- { $lang => [ Gettext => $langFile ] } );
+ {_decode => 1, $lang => [ Gettext => $langFile ] } ); #jomo - lexicon should return decoded strings
1;
}
)
@@ -320,7 +320,7 @@
#use the cache, if available
if ( open LANGUAGE, '<', "$Foswiki::cfg{WorkingDir}/languages.cache" ) {
$cache_open = 1;
- foreach my $line (<LANGUAGE>) {
+ foreach my $line (map { Encode::decode('utf-8', $_) } <LANGUAGE>) { #jomo - decode the utf8 file
my ( $key, $name ) = split( '=', $line );
# Filter on enabled languages
one more patch
@@ -339,7 +339,7 @@
foreach my $tag ( available_languages() ) {
my $h = Foswiki::I18N->get_handle($tag);
my $name = eval { $h->maketext("_language_name") } or next;
- print LANGUAGE "$tag=$name\n" if $cache_open;
+ print LANGUAGE Encode::encode_utf8("$tag=$name\n") if $cache_open;
# Filter on enabled languages
next
Screenshots
- before patch:
- after the patch:
--
JozefMojzis - 09 May 2015
Done, waiting for push.
--
CrawfordCurrie - 10 May 2015