#!/bin/sh # # This script attempts to check that catalog files of a certain package # (or all packages if no package key is provided) are consistent with # eachother and that they are consistent with lookups in the code. More # specifically the script does the following: # # 1) Checks that the info in the catalog filename matches info in # its xml content (package_key, locale and charset). # # 2) Checks that the set of keys in the message catalog is identical to the # set of keys in the adp, info, sql, and tcl files in the package. # # 3) Checks that the set of keys in non-en_US catalog files is present # in the en_US catalog file of the package. # # 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. # # usage: check-catalog.sh [package_key] # # @author Peter Marklund (peter@collaboraid.biz) ### Functions start get_catalog_keys() { file_name=$1 echo $(${script_path}/mygrep '" $en_US_file || echo "$0: $package_key - Warning: key $catalog_key in $file_name missing in $en_US_file" done done } check_catalog_keys_have_lookups() { # Check that all keys in the catalog file are either in tcl or adp or info files for catalog_key in `get_catalog_keys catalog/${package_key}.en_US.ISO-8859-1.xml` do lookup_lines=$(find ../ -regex '.*\.\(info\|adp\|sql\|tcl\)' | xargs egrep "${package_key}\.$catalog_key") if [ -z "$lookup_lines" ]; then echo "$0: $package_key - Warning key $catalog_key in catalog file not found in any adp, info, sql, or tcl file" fi done } check_tcl_file_lookups_are_in_catalog() { # Check that all message lookups in tcl files have entries in the message catalog for tcl_message_key in $(find ../ -iname '*.tcl'|xargs ${script_path}/mygrep \ "(?ms)\[_\s+(?:\[ad_conn locale\]\s+)?\"?${package_key}\.([a-zA-Z0-9_\-\.]+)\"?") do egrep -q "