]> sipb.mit.edu Git - ikiwiki.git/commitdiff
po: Fix copy of po file from underlay when editing
authorJoey Hess <joey@gnu.kitenet.net>
Mon, 10 Aug 2009 19:59:32 +0000 (15:59 -0400)
committerJoey Hess <joey@gnu.kitenet.net>
Mon, 10 Aug 2009 19:59:32 +0000 (15:59 -0400)
When first editing a page that was in the underlay, avoid losing
the translation by copying the po file over from the underlay.

IkiWiki/Plugin/po.pm
doc/plugins/po.mdwn

index 0ae4adcfccc8f94a4c21ecbbc003b768617c9a19..e9dc9dd8cfc2ba7dd0ed5291434c48a795bde50a 100644 (file)
@@ -827,6 +827,21 @@ sub refreshpofiles ($@) {
 
        foreach my $pofile (@pofiles) {
                IkiWiki::prep_writefile(basename($pofile),dirname($pofile));
 
        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) ".
                if (-e $pofile) {
                        system("msgmerge", "--previous", "-q", "-U", "--backup=none", $pofile, $potfile) == 0
                                or error("po(refreshpofiles) ".
index 0c8110563ff72a32114da1d45c34983cbe0e10b0..2fbf67016b173f747d09245786a131923a60f062 100644 (file)
@@ -277,17 +277,6 @@ That used to be so, but the bug was fixed. Does this mean
 that po might be replacing the only link on a page, in error? 
 --[[Joey]] 
 
 that po might be replacing the only link on a page, in error? 
 --[[Joey]] 
 
-Bug when editing underlay file
-------------------------------
-
-While I've gotten translated underlays working, there is a bug
-if the wiki is currently using a page from the underlay, and the master
-language version is edited. This causes the edited page to be saved
-to srcdir.. and all the translations get set to 0% and their
-po files have the translated strings "emptied". What's really going on
-is that these are entirely new po files not based on the old ones
-in the basewiki, and thus lacking translations. --[[Joey]] 
-
 Documentation
 -------------
 
 Documentation
 -------------