[interchange-cvs] interchange - racke modified dist/etc/jobs/i18n/update_locales

interchange-core@icdevgroup.org interchange-core@icdevgroup.org
Tue Feb 18 11:02:01 2003


User:      racke
Date:      2003-02-18 16:01:52 GMT
Modified:  dist/etc/jobs/i18n update_locales
Log:
examines templates directory as well now, with a little help of its friend,
$Tag->find

Revision  Changes    Path
1.2       +20 -20    interchange/dist/etc/jobs/i18n/update_locales


rev 1.2, prev_rev 1.1
Index: update_locales
===================================================================
RCS file: /anon_cvs/repository/interchange/dist/etc/jobs/i18n/update_locales,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- update_locales	13 Feb 2003 16:14:42 -0000	1.1
+++ update_locales	18 Feb 2003 16:01:52 -0000	1.2
@@ -2,39 +2,39 @@
 
 [perl tables=`$Config->{LocaleDatabase}`]
 
-my ($pset, $pdir, $contents);
+my ($pset, $pdir, $contents, $file, $newrecs);
 my (@locs);
 my $db = $Db{$Config->{LocaleDatabase}};
 
-# get all pages
-$pset = $Tag->list_pages({arrayref => 1});
-
-# get the relative page dir
+# get the relative directory where the pages reside
 if (index($Config->{PageDir}, "$Config->{VendRoot}/")) {
     return "$Config->{PageDir} not relative to $Config->{VendRoot}.";
 }
 $pdir = substr($Config->{PageDir}, length($Config->{VendRoot}) + 1);
 
-for (@$pset) {
-        # get contents of current page
-        $contents = $Tag->file("$pdir/$_$Config->{HTMLsuffix}");
+# get all pages, templates and components
+@files = $Tag->find({}, [$pdir, 'templates']);
 
-        # find [L ...]...[/L]
-        while ($contents =~ m:\[L(\s+(\w+)\s*)?\](.*?)\[/L\]:sg) {
-                push (@out, [$2 || $3, $3]);
-        } 
-        # find [msg arg.0="..." arg.1="..."]...[/msg]
-        while ($contents =~ m:\[msg(\s+arg\.\d+=".*?")*\s*\](\s*[^\[].*?[^\]]\s*)\[/msg\]:gsi) {
-                push (@out, [$2, $2]);
-        }
+for $file (@files) {
+    # get contents of current page
+    $contents = $Tag->file($file);
+    # find [L ...]...[/L]
+    while ($contents =~ m:\[L(\s+(\w+)\s*)?\](.*?)\[/L\]:sg) {
+        push (@out, [$2 || $3, $3]);
+    } 
+    
+    # find [msg arg.0="..." arg.1="..."]...[/msg]
+    while ($contents =~ m:\[msg(\s+arg\.\d+=".*?")*\s*\](\s*[^\[].*?[^\]]\s*)\[/msg\]:gsi) {
+        push (@out, [$2, $2]);
+    }
 }
 
 for (@out) {
     unless ($db->record_exists($_->[0])) {
-                Log ("No entry for $_->[0] in locale database");
-                $db->set_slice($_->[0], { en_US => $_->[1] });
-        }
+        $db->set_slice($_->[0], { en_US => $_->[1] });
+		$newrecs++;
+    }
 }
-
+return sprintf("Update locales: %d records found, %d new", scalar(@out), $newrecs); 
 [/perl]