Index: openacs-4/packages/acs-admin/www/apm/version-i18n.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/apm/version-i18n.adp,v diff -u -r1.4 -r1.5 --- openacs-4/packages/acs-admin/www/apm/version-i18n.adp 21 Oct 2002 11:41:01 -0000 1.4 +++ openacs-4/packages/acs-admin/www/apm/version-i18n.adp 21 Oct 2002 16:54:28 -0000 1.5 @@ -174,3 +174,77 @@ When you feel ready you may run the action "Replace tags with keys and insert into catalog" on the tcl files that you've edited to replace the temporary tags with calls to the message lookup procedure.

+ +

Checking the Consistency of the Catalog File

+ +

+This section describes how we checked that the set of keys used in message lookups +in tcl, adp, and info files and the set of keys in the catalog file are identical. +The scripts below assume that message lookups in adp and info files are on the format +\#package_key.message_key\#, and that message lookups in tcl files are always done with +the underscore procedure. +

+ +

+To check that all keys in the dotlrn catalog file are actually used in message lookups in either +tcl or adp or info files, we used: +

+ +
+# Check that all keys in the catalog file are either in tcl or adp or info files
+for catalog_key in $(mygrep '<msg key="([^"]+)"' catalog/dotlrn.en_US.ISO-8859-1.xml); do find -iname '*.tcl'|xargs mygrep "(?ms)\[_\s+(?:\[ad_conn locale\]\s+)?\"?dotlrn\.$catalog_key\"?" || find -regex '.*\.\(info\|adp\)'|xargs mygrep '#dotlrn\.[a-zA-Z0-9_\.]+#' || echo "Warning key $catalog_key in catalog file not found in any adp or tcl file"; done
+
+ +

+Conversely, in order too check that all +keys in the message lookups in the adp, info, and tcl files have entries in the en_US catalog file we used +the following command lines for the dotlrn package: +

+ +
+# Check that all message lookups in tcl files have entries in the message catalog (should return nothing)
+for tcl_message_key in $(find -iname '*.tcl'|xargs mygrep '(?ms)\[_\s+(?:\[ad_conn locale\]\s+)?"?dotlrn\.([a-zA-Z0-9_\.]+)"?'); do grep -L $tcl_message_key catalog/dotlrn.en_US.ISO-8859-1.xml || echo "Warning: key $tcl_message_key not in catalog file"; done
+# Check that all message lookups in adp and info files are in the catalog file
+for adp_message_key in $(find -regex '.*\.\(info\|adp\)'|xargs mygrep '#dotlrn\.([a-zA-Z0-9_\.]+)#'); do grep -L $adp_message_key catalog/dotlrn.en_US.ISO-8859-1.xml || echo "Warning: key $adp_message_key not in catalog file"; done
+
+ +The mygrep script used above is: + +
+#!/usr/bin/perl -w
+#
+# Loops through the input (input taken from files on the command line or from STDIN)
+# line by line and prints what was captured in the first
+# parenthesis of the pattern. Start the pattern with (?i) for case insensitive matching.
+# Use -m to match across multiple lines.
+#
+# Usage: mygrep [-m]  [files...]
+#
+
+if ($ARGV[0] =~ /^-m/) {
+      shift;
+      # Undefine the record separator to read the whole file in one go
+      undef $/;
+      $pattern = shift;
+      # Let . match newline
+      if ($pattern !~ /^\w*\(\?\w*s\w*\)/) {
+	  $pattern = "(?s)$pattern";
+      }
+} else {
+    $pattern = shift;
+}
+
+# Take input from STDIN or from files
+my $have_match = 0;
+while ($line = <>) {
+    if ($line =~ /$pattern/) {
+        if (defined($1)) {
+            print STDOUT "$1\n";
+        }
+        
+        $have_match = 1;
+    } 
+}
+
+$have_match ? exit 0 : exit 1;
+