]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/po.pm
po plugin: force utf-8 encoding in POT files
[ikiwiki.git] / IkiWiki / Plugin / po.pm
index 127d6d47f3496d2aa5c19c126cbb66ed5ec4793b..59d938d821151a1f9f0ec3bac27c1a18f8c406ec 100644 (file)
@@ -35,7 +35,6 @@ sub import {
        hook(type => "getsetup", id => "po", call => \&getsetup);
        hook(type => "checkconfig", id => "po", call => \&checkconfig);
        hook(type => "needsbuild", id => "po", call => \&needsbuild);
-       hook(type => "tweakurlpath", id => "po", call => \&tweakurlpath);
        hook(type => "filter", id => "po", call => \&filter);
        hook(type => "htmlize", id => "po", call => \&htmlize);
        hook(type => "pagetemplate", id => "po", call => \&pagetemplate);
@@ -135,6 +134,7 @@ sub refreshpot ($) { #{{{
        # compulsory since this module prevents us from using the porefs option.
        my %po_options = ('porefs' => 'none');
        $doc->{TT}{po_out}=Locale::Po4a::Po->new(\%po_options);
+       $doc->{TT}{po_out}->set_charset('utf-8');
        # do the actual work
        $doc->parse;
        $doc->writepo($potfile);
@@ -226,7 +226,7 @@ sub mytargetpage ($$) { #{{{
 
        if (istranslation($page)) {
                my ($masterpage, $lang) = ($page =~ /(.*)[.]([a-z]{2})$/);
-               if (! $config{usedirs} || $page eq 'index') {
+               if (! $config{usedirs} || $masterpage eq 'index') {
                        return $masterpage . "." . $lang . "." . $ext;
                }
                else {
@@ -253,6 +253,17 @@ sub mybeautify_urlpath ($) { #{{{
        return $res;
 } #}}}
 
+sub urlto_with_orig_beautiful_urlpath($$) { #{{{
+       my $to=shift;
+       my $from=shift;
+
+       inject(name => "IkiWiki::beautify_urlpath", call => $origsubs{'beautify_urlpath'});
+       my $res=urlto($to, $from);
+       inject(name => "IkiWiki::beautify_urlpath", call => \&mybeautify_urlpath);
+
+       return $res;
+} #}}}
+
 sub mybestlink ($$) { #{{{
        my $page=shift;
        my $link=shift;
@@ -360,7 +371,7 @@ sub otherlanguages ($) { #{{{
        elsif (istranslation($page)) {
                my ($masterpage, $curlang) = ($page =~ /(.*)[.]([a-z]{2})$/);
                push @ret, {
-                       url => urlto($masterpage, $page),
+                       url => urlto_with_orig_beautiful_urlpath($masterpage, $page),
                        code => $config{po_master_language}{code},
                        language => $config{po_master_language}{name},
                        master => 1,