X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/f5c8fca8875e2ad76134c15bc7717ccd21cb2e18..669a5f5ecc0d50daf96d8dc2af219c94c8625fb4:/IkiWiki/Plugin/po.pm diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 6410a1c66..6107a4a22 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -23,7 +23,6 @@ use File::Copy; use File::Spec; use File::Temp; use Memoize; -use UNIVERSAL; my ($master_language_code, $master_language_name); my %translations; @@ -48,7 +47,7 @@ sub import { hook(type => "pagetemplate", id => "po", call => \&pagetemplate, last => 1); hook(type => "rename", id => "po", call => \&renamepages, first => 1); hook(type => "delete", id => "po", call => \&mydelete); - hook(type => "change", id => "po", call => \&change); + hook(type => "rendered", id => "po", call => \&rendered); hook(type => "checkcontent", id => "po", call => \&checkcontent); hook(type => "canremove", id => "po", call => \&canremove); hook(type => "canrename", id => "po", call => \&canrename); @@ -347,6 +346,12 @@ sub pagetemplate (@) { if ($template->query(name => "lang_code")) { $template->param(lang_code => $lang_code); } + if ($template->query(name => "html_lang_code")) { + $template->param(html_lang_code => htmllangcode($lang_code)); + } + if ($template->query(name => "html_lang_dir")) { + $template->param(html_lang_dir => htmllangdir($lang_code)); + } if ($template->query(name => "lang_name")) { $template->param(lang_name => languagename($lang_code)); } @@ -428,7 +433,7 @@ sub mydelete (@) { map { deletetranslations($_) } grep istranslatablefile($_), @deleted; } -sub change (@) { +sub rendered (@) { my @rendered=@_; my $updated_po_files=0; @@ -858,6 +863,19 @@ sub lang ($) { return $master_language_code; } +sub htmllangcode ($) { + (my $lang = shift) =~ tr/_/-/; + return $lang; +} + +sub htmllangdir ($) { + my $lang = shift; + if ($lang =~ /^(ar|fa|he)/) { + return 'rtl'; + } + return 'ltr'; +} + sub islanguagecode ($) { my $code=shift; @@ -1054,6 +1072,8 @@ sub otherlanguagesloop ($) { push @ret, { url => urlto_with_orig_beautiful_urlpath(masterpage($page), $page), code => $master_language_code, + html_code => htmllangcode($master_language_code), + html_dir => htmllangdir($master_language_code), language => $master_language_name, master => 1, }; @@ -1064,6 +1084,8 @@ sub otherlanguagesloop ($) { push @ret, { url => urlto_with_orig_beautiful_urlpath($otherpage, $page), code => $lang, + html_code => htmllangcode($lang), + html_dir => htmllangdir($lang), language => languagename($lang), percent => percenttranslated($otherpage), } @@ -1103,7 +1125,7 @@ sub deletetranslations ($) { IkiWiki::rcs_remove($_); } else { - IkiWiki::prune("$config{srcdir}/$_"); + IkiWiki::prune("$config{srcdir}/$_", $config{srcdir}); } } @todelete;