diff options
author | Joey Hess <joey@kitenet.net> | 2014-02-23 14:06:40 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-02-23 14:06:40 -0400 |
commit | 9a99c4c6e2228954b27e1e93e2b66c12a74850ac (patch) | |
tree | e86ea4b7b4431967e86278e1c21c5a76386f4013 /IkiWiki | |
parent | 278036ef45c30cccf4e30cbb899521bdc4ebb202 (diff) | |
parent | 062b196f51bcca07c42b79b01e0075cf68a65157 (diff) | |
download | ikiwiki-9a99c4c6e2228954b27e1e93e2b66c12a74850ac.tar ikiwiki-9a99c4c6e2228954b27e1e93e2b66c12a74850ac.tar.gz |
Merge remote-tracking branch 'mhameed/html_lang_and_dir'
Diffstat (limited to 'IkiWiki')
-rw-r--r-- | IkiWiki/Plugin/po.pm | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 53e6af92f..6107a4a22 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -346,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)); } @@ -857,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; @@ -1053,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, }; @@ -1063,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), } |