diff options
author | Mesar Hameed <mhameed@src.gnome.org> | 2013-10-14 12:47:48 +0200 |
---|---|---|
committer | Mesar Hameed <mhameed@src.gnome.org> | 2013-10-14 12:47:48 +0200 |
commit | 062b196f51bcca07c42b79b01e0075cf68a65157 (patch) | |
tree | 70dec3183bf1f22d3d3d1b63bd154957b059b079 /IkiWiki | |
parent | 6c9945b1c30b6de3da25923d5e9ac1b19d020007 (diff) | |
download | ikiwiki-062b196f51bcca07c42b79b01e0075cf68a65157.tar ikiwiki-062b196f51bcca07c42b79b01e0075cf68a65157.tar.gz |
Add two template variables, expose html language code and language direction.
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), } |