Example 16-2. catalog-compare.php
$base = 'pc_MC_'.$_SERVER['argv'][1];
$other = 'pc_MC_'.$_SERVER['argv'][2];
require 'pc_MC_Base.php';
require "$base.php";
require "$other.php";
$base_obj = new $base;
$other_obj = new $other;
/* Check for messages in the other class that
* are the same as the base class or are in
* the base class but missing from the other class */
foreach ($base_obj->messages as $k => $v) {
if (isset($other_obj->messages[$k])) {
if ($v == $other_obj->messages[$k]) {
print "SAME: $k\n";
}
} else {
print "MISSING: $k\n";
}
}
/* Check for messages in the other class but missing
* from the base class */
foreach ($other_obj->messages as $k => $v) {
if (! isset($base_obj->messages[$k])) {
print "MISSING (BASE): $k\n";
}
}
To use this program, put each message catalog object in a file with
the same name as the object (e.g., the pc_MC_en_US
class should be in a file named pc_MC_en_US.php,
and the pc_MC_es_US class should be in a file
named pc_MC_es_US.php). You then call the
program with the two locale names as arguments on the command line:
% php catalog-compare.php en_US es_US