Item13399: Display error in trunk/utf8 branch... easy fixes.

pencil
Priority: Normal
Current State: Closed
Released In: n/a
Target Release: n/a
Applies To: Engine
Component: Utf8Branch
Branches: master
Reported By: JozefMojzis
Waiting For:
Last Change By: CrawfordCurrie

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:
    screenshot 68.png

  • after the patch:
    screenshot 69.png

-- JozefMojzis - 09 May 2015

Done, waiting for push.

-- CrawfordCurrie - 10 May 2015
 
I Attachment Action Size Date Who Comment
screenshot_68.pngpng screenshot_68.png manage 71 K 09 May 2015 - 08:38 JozefMojzis before patch
screenshot_69.pngpng screenshot_69.png manage 67 K 09 May 2015 - 08:39 JozefMojzis after the patch
Topic revision: r5 - 19 May 2015, CrawfordCurrie
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy