[Jifty-commit] r5898 - jifty/trunk/lib/Jifty/Script

Jifty commits jifty-commit at lists.jifty.org
Thu Oct 2 13:39:48 EDT 2008


Author: clkao
Date: Thu Oct  2 13:39:48 2008
New Revision: 5898

Modified:
   jifty/trunk/lib/Jifty/Script/Po.pm

Log:
when generating non-core po, remove the entries already
exist in core, unless it's locally translated.


Modified: jifty/trunk/lib/Jifty/Script/Po.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Script/Po.pm	(original)
+++ jifty/trunk/lib/Jifty/Script/Po.pm	Thu Oct  2 13:39:48 2008
@@ -160,11 +160,37 @@
 
     $LMExtract->read_po($translation) if ( -f $translation && $translation !~ m/pot$/ );
 
+    my $orig_lexicon;
+
     # Reset previously compiled entries before a new compilation
     $LMExtract->set_compiled_entries;
     $LMExtract->compile(USE_GETTEXT_STYLE);
 
-    $LMExtract->write_po($translation);
+    if ($self->_is_core && !$self->{'template_name'}) {
+        $LMExtract->write_po($translation);
+    }
+    else {
+        $orig_lexicon = $LMExtract->lexicon;
+        my $lexicon = { %$orig_lexicon };
+
+        # XXX: cache core_lm
+        my $core_lm = Locale::Maketext::Extract->new();
+        Locale::Maketext::Lexicon::set_option('allow_empty' => 1);
+        $core_lm->read_po( File::Spec->catfile(
+            Jifty->config->framework('L10N')->{'DefaultPoDir'}, 'jifty.pot'
+        ));
+        Locale::Maketext::Lexicon::set_option('allow_empty' => 0);
+        for (keys %{ $core_lm->lexicon }) {
+            next unless exists $lexicon->{$_};
+            # keep the local entry overriding core if it exists
+            delete $lexicon->{$_} unless length $lexicon->{$_};
+        }
+        $LMExtract->set_lexicon($lexicon);
+
+        $LMExtract->write_po($translation);
+
+        $LMExtract->set_lexicon($orig_lexicon);
+    }
 }
 
 


More information about the Jifty-commit mailing list