12 import(
'classes.handler.Handler');
21 $context = $request->getContext();
24 $customLocaleDir = $contextFileManager->getBasePath() .
'customLocale';
25 if (!file_exists($customLocaleDir) || !is_dir($customLocaleDir))
throw new Exception(
"Path \"$customLocaleDir\" does not exist!");
28 $directory =
new RecursiveDirectoryIterator($customLocaleDir);
29 $iterator =
new RecursiveIteratorIterator($directory);
30 $regex =
new RegexIterator($iterator,
'/^.+\.xml$/i', RecursiveRegexIterator::GET_MATCH);
31 $files = iterator_to_array($regex);
32 $fileKeys = array_keys($files);
36 import(
'lib.pkp.classes.i18n.LocaleFile');
38 foreach ($fileKeys as $pathToFile) {
39 $posLib = strpos($pathToFile,
'lib');
40 $posLocale = strpos($pathToFile,
'locale');
41 $posPlugins = strpos($pathToFile,
'plugins');
44 if (!$posLib===
false) {
45 $localeFile = substr($pathToFile,$posLib);
46 }
else if (!$posPlugins===
false) {
47 $localeFile = substr($pathToFile,$posPlugins);
50 $localeFile = substr($pathToFile,$posLocale);
53 $localeContentsCustomized =
null;
54 if ($contextFileManager->fileExists($pathToFile)) {
58 $localeContents =
null;
59 if ($contextFileManager->fileExists($localeFile)) {
63 $localeKeys = array_keys($localeContentsCustomized);
65 if (
sizeof($localeKeys)>0) {
66 $output = $output .
"\nFile: " . $localeFile;
69 foreach ($localeKeys as $index => $localeKey) {
70 $output = $output .
"\n\n" . $index+1 .
'. locale key: ' . $localeKey;
71 $output = $output .
"\n\n original content: " . $localeContents[$localeKey];
72 $output = $output .
"\n customized content: " . $localeContentsCustomized[$localeKey];
74 if (!empty($localeKeys)) {
75 $output = $output .
"\n\n__________________________________________________________________________________\n\n";
79 $filename =
'customLocale_changes.txt';
80 header(
'Content-Type: text/plain');
81 header(
'Content-Disposition: attachment; filename="'.$filename.
'"');
82 header(
'Content-Length: ' . strlen($output));