summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2009-08-10 15:59:32 -0400
committerJoey Hess <joey@gnu.kitenet.net>2009-08-10 15:59:32 -0400
commit83480665c256a344900fc817bcb4618f8db9aeee (patch)
tree66802a72ed34822670326bad48bf270161a37850 /IkiWiki/Plugin
parent8c4325d2ceb50533cea01128d119ff19fba2ea44 (diff)
po: Fix copy of po file from underlay when editing
When first editing a page that was in the underlay, avoid losing the translation by copying the po file over from the underlay.
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r--IkiWiki/Plugin/po.pm15
1 files changed, 15 insertions, 0 deletions
diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm
index 0ae4adcfc..e9dc9dd8c 100644
--- a/IkiWiki/Plugin/po.pm
+++ b/IkiWiki/Plugin/po.pm
@@ -827,6 +827,21 @@ sub refreshpofiles ($@) {
foreach my $pofile (@pofiles) {
IkiWiki::prep_writefile(basename($pofile),dirname($pofile));
+
+ if (! -e $pofile) {
+ # If the po file exists in an underlay, copy it
+ # from there.
+ my ($pobase)=$pofile=~/^\Q$config{srcdir}\E\/?(.*)$/;
+ foreach my $dir (@{$config{underlaydirs}}) {
+ if (-e "$dir/$pobase") {
+ File::Copy::syscopy("$dir/$pobase",$pofile)
+ or error("po(refreshpofiles) ".
+ sprintf(gettext("failed to copy underlay PO file to %s"),
+ $pofile));
+ }
+ }
+ }
+
if (-e $pofile) {
system("msgmerge", "--previous", "-q", "-U", "--backup=none", $pofile, $potfile) == 0
or error("po(refreshpofiles) ".