Index: openacs-4/packages/acs-lang/bin/check-catalog-file-path.pl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/bin/check-catalog-file-path.pl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-lang/bin/check-catalog-file-path.pl 29 Oct 2002 17:58:27 -0000 1.1 @@ -0,0 +1,35 @@ +#!/usr/bin/perl -w +# +# Check that a catalog file has a consistent path and that package_key, locale, and +# charset info in the xml is consistent with info embedded in the filename. +# +# @author Peter Marklund + +my $usage = "catalog-file-name.pl catalog_file_path"; + +use strict; + +# Get arguments +my $file_path = shift or die "usage: $usage"; + +# Parse information from the file path +$file_path =~ m#(?i)([a-z-]+)/catalog/\1\.([a-z]{2}_[a-z]{2})\.(.*)\.xml$# + or die "catalog file path $file_path is not on format package_key/catalog/package_key.locale.charset.xml"; +my ($file_package, $file_locale, $file_charset) = ($1, $2, $3, $4); + +# Get the same info from the xml of the catalog file +open(FILE_INPUT, "< $file_path"); +# Undefine the record separator to read the whole file in one go +undef $/; +my $file_contents = ; +$file_contents =~ m## + or die "catalog file $file_path does not have a root xml node on parsable format"; +my ($xml_package, $xml_locale, $xml_charset) = ($1, $2, $3); + +# Assert that info in filename and xml be the same +if ( $file_package ne $xml_package || + $file_locale ne $xml_locale || + $file_charset ne $xml_charset) { + + die "FAILURE: $file_path does not pass check since info in file path ($file_package, $file_locale, $file_charset) does not match info in xml ($xml_package, $xml_locale, $xml_charset)\n"; +} Index: openacs-4/packages/acs-lang/bin/check-catalog.sh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/bin/check-catalog.sh,v diff -u -r1.4 -r1.5 --- openacs-4/packages/acs-lang/bin/check-catalog.sh 29 Oct 2002 08:04:53 -0000 1.4 +++ openacs-4/packages/acs-lang/bin/check-catalog.sh 29 Oct 2002 17:58:27 -0000 1.5 @@ -3,6 +3,9 @@ # Check consistency of the en_US message catalog of the given package. # Checks that the set of keys in the message catalog is identical to the # set of keys in the adp, info, and tcl files in the package. +# Also checks that the info in the catalog filename matches info in +# its xml content (package_key, locale and charset). +# # The scripts assumes 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. @@ -84,6 +87,9 @@ package_path="${script_path}/../../${package_key}" cd $package_path +echo "$0: $package_key - checking catalog file name" +${script_path}/check-catalog-file-path.pl $catalog_file_path + echo "$0: $package_key - checking catalog keys are in lookups" check_catalog_keys_have_lookups $package_key