| 1 |
<? |
|---|
| 2 |
|
|---|
| 3 |
# this config block lists the regexps to run against strings in language files |
|---|
| 4 |
# |
|---|
| 5 |
# we can use this to check that translated versions have the required magic |
|---|
| 6 |
# characters, such as the ^^linked word^^ syntax. |
|---|
| 7 |
# |
|---|
| 8 |
|
|---|
| 9 |
$rx_hats = '!\^\^(.*?)\^\^!'; |
|---|
| 10 |
|
|---|
| 11 |
$check = array( |
|---|
| 12 |
'installer.properties' => array( |
|---|
| 13 |
'title.version' => '!\${VERSION}!', |
|---|
| 14 |
'title.version.inst' => '!\${VERSION}!', |
|---|
| 15 |
), |
|---|
| 16 |
'main.dtd' => array( |
|---|
| 17 |
'help.offline' => $rx_hats, |
|---|
| 18 |
'help.drag' => $rx_hats, |
|---|
| 19 |
'help.faq' => $rx_hats, |
|---|
| 20 |
'!photos.init.text.joined' => '!.+!', |
|---|
| 21 |
), |
|---|
| 22 |
'main.properties' => array( |
|---|
| 23 |
'video.add.restricted.sz.guidelines' => $rx_hats, |
|---|
| 24 |
'video.add.restricted.pz.guidelines' => $rx_hats, |
|---|
| 25 |
'video.add.restricted.sp.guidelines' => $rx_hats, |
|---|
| 26 |
'video.add.restricted.pp.guidelines' => $rx_hats, |
|---|
| 27 |
'video.edit.restricted.sz.guidelines' => $rx_hats, |
|---|
| 28 |
'video.edit.restricted.pz.guidelines' => $rx_hats, |
|---|
| 29 |
'video.edit.restricted.sp.guidelines' => $rx_hats, |
|---|
| 30 |
'video.edit.restricted.pp.guidelines' => $rx_hats, |
|---|
| 31 |
), |
|---|
| 32 |
'proxy.dtd' => array( |
|---|
| 33 |
'connectionDesc.label' => '!\&brandShortName\;!', |
|---|
| 34 |
), |
|---|
| 35 |
); |
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
# ignore everything below this line :) |
|---|
| 40 |
# |
|---|
| 41 |
|
|---|
| 42 |
######################################################################################### |
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
$locales = dirname(__FILE__).'/MacUploadr.app/Contents/Resources/chrome/locale'; |
|---|
| 46 |
|
|---|
| 47 |
$dh = opendir($locales); |
|---|
| 48 |
while ($file = readdir($dh)){ |
|---|
| 49 |
|
|---|
| 50 |
if (is_dir("$locales/$file") && preg_match('!^[a-z0-9]{2}-[a-z0-9]{2}$!i', $file)){ |
|---|
| 51 |
|
|---|
| 52 |
check_language($file, $check); |
|---|
| 53 |
} |
|---|
| 54 |
} |
|---|
| 55 |
closedir($dh); |
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
function check_language($lang, $check){ |
|---|
| 60 |
|
|---|
| 61 |
echo "checking $lang: "; flush(); |
|---|
| 62 |
|
|---|
| 63 |
foreach ($check as $file => $strings){ |
|---|
| 64 |
|
|---|
| 65 |
$catalogue = load_strings($lang, $file); |
|---|
| 66 |
|
|---|
| 67 |
foreach ($strings as $key => $rx){ |
|---|
| 68 |
|
|---|
| 69 |
if ($key{0} == '!'){ |
|---|
| 70 |
|
|---|
| 71 |
if (preg_match($rx, $catalogue[substr($key, 1)])){ |
|---|
| 72 |
|
|---|
| 73 |
echo "\nMatched $rx against $catalogue[$key]\n"; |
|---|
| 74 |
|
|---|
| 75 |
}else{ |
|---|
| 76 |
echo '.'; flush(); |
|---|
| 77 |
} |
|---|
| 78 |
|
|---|
| 79 |
}else{ |
|---|
| 80 |
|
|---|
| 81 |
if (!preg_match($rx, $catalogue[$key])){ |
|---|
| 82 |
|
|---|
| 83 |
echo "\nFailed to match $rx against $catalogue[$key]\n"; |
|---|
| 84 |
|
|---|
| 85 |
}else{ |
|---|
| 86 |
echo '.'; flush(); |
|---|
| 87 |
} |
|---|
| 88 |
} |
|---|
| 89 |
} |
|---|
| 90 |
} |
|---|
| 91 |
|
|---|
| 92 |
echo "done\n"; flush(); |
|---|
| 93 |
} |
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
function load_strings($lang, $filename){ |
|---|
| 98 |
|
|---|
| 99 |
$path = dirname(__FILE__).'/MacUploadr.app/Contents/Resources/chrome/locale/'.$lang.'/'.$filename; |
|---|
| 100 |
|
|---|
| 101 |
$lines = file($path); |
|---|
| 102 |
$dict = array(); |
|---|
| 103 |
|
|---|
| 104 |
if (preg_match('!\.dtd$!', $filename)){ |
|---|
| 105 |
|
|---|
| 106 |
foreach ($lines as $line){ |
|---|
| 107 |
|
|---|
| 108 |
if (preg_match('!ENTITY\s+([A-Za-z0-9._]+)\s+"([^"]+)"!', $line, $m)){ |
|---|
| 109 |
|
|---|
| 110 |
$dict[$m[1]] = $m[2]; |
|---|
| 111 |
} |
|---|
| 112 |
} |
|---|
| 113 |
} |
|---|
| 114 |
|
|---|
| 115 |
if (preg_match('!\.properties$!', $filename)){ |
|---|
| 116 |
|
|---|
| 117 |
foreach ($lines as $line){ |
|---|
| 118 |
|
|---|
| 119 |
if (preg_match('!^([a-z0-9-.]+)=(.*)$!i', $line, $m)){ |
|---|
| 120 |
|
|---|
| 121 |
$dict[$m[1]] = $m[2]; |
|---|
| 122 |
} |
|---|
| 123 |
} |
|---|
| 124 |
} |
|---|
| 125 |
|
|---|
| 126 |
return $dict; |
|---|
| 127 |
} |
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 |
?> |
|---|