use File::Spec;
use File::Temp;
use Memoize;
-use UNIVERSAL;
my ($master_language_code, $master_language_name);
my %translations;
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);
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));
}
map { deletetranslations($_) } grep istranslatablefile($_), @deleted;
}
-sub change (@) {
+sub rendered (@) {
my @rendered=@_;
my $updated_po_files=0;
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;
}
if (-e $pofile) {
- system("msgmerge", "--previous", "-q", "-U", "--backup=none", $pofile, $potfile) == 0
- or error("po(refreshpofiles) ".
- sprintf(gettext("failed to update %s"),
- $pofile));
+ if (! (system("msgmerge", "--previous", "-q", "-U", "--backup=none", $pofile, $potfile) == 0)) {
+ print STDERR ("po(refreshpofiles) ". sprintf(gettext("failed to update %s"), $pofile));
+ }
}
else {
File::Copy::syscopy($potfile,$pofile)
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,
};
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),
}
IkiWiki::rcs_remove($_);
}
else {
- IkiWiki::prune("$config{srcdir}/$_");
+ IkiWiki::prune("$config{srcdir}/$_", $config{srcdir});
}
} @todelete;