[vhffs-dev] [1864] Modified i18n extraction script.

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 1864
Author:   beuss
Date:     2011-06-03 12:43:59 +0200 (Fri, 03 Jun 2011)
Log Message:
-----------
Modified i18n extraction script.

Now you know where your string come from.

Added Paths:
-----------
    trunk/vhffs-intl/update-POTFILES.in.pl

Removed Paths:
-------------
    trunk/vhffs-intl/update-POTFILES.in.sh

Added: trunk/vhffs-intl/update-POTFILES.in.pl
===================================================================
--- trunk/vhffs-intl/update-POTFILES.in.pl	                        (rev 0)
+++ trunk/vhffs-intl/update-POTFILES.in.pl	2011-06-03 10:43:59 UTC (rev 1864)
@@ -0,0 +1,62 @@
+#!/usr/bin/perl
+=head1 update-POTFILE.in.pl - Updates i18n strings
+
+This script generates a list of files that may contain
+internationalized strings. It also extract i15d strings from
+templates.
+
+=cut
+
+use strict;
+use warnings;
+
+use File::Basename;
+use File::Find;
+use File::Spec;
+
+my $script = File::Spec->rel2abs(__FILE__);
+my $src_root = dirname(dirname($script));
+my @src_subdirs = qw/vhffs-contrib vhffs-panel vhffs-listengine
+    vhffs-tools vhffs-mw vhffs-api vhffs-shells vhffs-public
+    vhffs-jabber vhffs-irc vhffs-stsmon vhffs-intl/;
+
+# First extract strings from templates
+
+my @tt_files;
+
+foreach my $sd(@src_subdirs) {
+    File::Find::find(sub {
+        push @tt_files, $File::Find::name if($File::Find::name =~ /\.tt$/)
+    }, File::Spec->catfile($src_root, $sd));
+}
+
+open STRINGS, '>', File::Spec->catfile($src_root, 'vhffs-intl', 'template_strings.pl');
+print STRINGS "#!/usr/bin/perl\nexit(0);\n";
+
+foreach my $f(@tt_files) {
+    open TT, '<', $f;
+    my $str;
+    while(<TT>) {
+        if(($str) = /\[%\s+'([^|]+?)'\s*\|\s*i18n\b/) {
+            print STRINGS "# $f:$.\n";
+            print STRINGS "gettext('$str');\n";
+        }
+    };
+    close TT;
+}
+
+close STRINGS;
+
+# Then make a list of 
+
+my @files;
+foreach my $sd(@src_subdirs) {
+    File::Find::find(sub {
+        push @files, $File::Find::name."\n" if($File::Find::name =~ /\.p[ml]$/);
+    }, File::Spec->catfile($src_root, $sd));
+}
+
+@files = sort @files;
+open POTFILES, '>', 'POTFILES.in';
+print POTFILES @files;
+close POTFILES;


Property changes on: trunk/vhffs-intl/update-POTFILES.in.pl
___________________________________________________________________
Added: svn:executable
   + *

Deleted: trunk/vhffs-intl/update-POTFILES.in.sh
===================================================================
--- trunk/vhffs-intl/update-POTFILES.in.sh	2011-06-03 10:43:49 UTC (rev 1863)
+++ trunk/vhffs-intl/update-POTFILES.in.sh	2011-06-03 10:43:59 UTC (rev 1864)
@@ -1,6 +0,0 @@
-#!/bin/bash
-VHFFS_DIRS='../vhffs-contrib ../vhffs-panel ../vhffs-forum ../vhffs-listengine ../vhffs-tools ../vhffs-mw ../vhffs-api ../vhffs-shells ../vhffs-public ../vhffs-jabber ../vhffs-irc ../vhffs-stsmon'
-find $VHFFS_DIRS -name '*.tt' | xargs perl -ne 'print "gettext(\"$1\");\n" if(/\[%\s+'\''([^|]+?)'\''\s*\|\s*i18n\b/);' > template_strings.pl.tmp
-sort template_strings.pl.tmp > template_strings.pl
-rm template_strings.pl.tmp
-find $VHFFS_DIRS -name '*.p[ml]' | sed s!^../!! | sort > 'POTFILES.in'


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/