echo " Ignoring: {$xmllang}\n"; continue; } else { echo " Mapped to: {$lang}\n"; } } else { $lang = $xmllang; } $langfile = "{$targetlangdir}/{$lang}/editor_tinymce.php"; if (!file_exists(dirname($langfile))) { mkdir(dirname($langfile), 0755, true); } if (file_exists($langfile)) { unlink($langfile); } $parsed = editor_tinymce_parse_xml_lang("{$tempdir}/{$xmlfile}"); ksort($parsed); if (!($handle = fopen($langfile, 'w'))) { echo "*** Cannot write to {$langfile} !!\n"; continue; } fwrite($handle, "<?php\n\n// upload this file into the AMOS stage, rebase the stage, review the changes and commit\n"); foreach ($parsed as $key => $value) { fwrite($handle, editor_tinymce_encode_stringline($key, $value)); } fclose($handle); } unset($xmlfiles); die("\nFinished!\n\n"); /// ============ Utility functions ======================== function editor_tinymce_encode_stringline($key, $value)
$langfile = "{$targetlangdir}/{$lang}/editor_tinymce.php"; if (file_exists($langfile)) { $old_strings = editor_tinymce_get_all_strings($langfile); ksort($old_strings); foreach ($old_strings as $key => $value) { if (!array_key_exists($key, $en_strings)) { unset($old_strings[$key]); } } } else { $old_strings = array(); } // our modifications and upstream changes in existing strings $tweaked = array(); //detect changes and new additions $parsed = editor_tinymce_parse_xml_lang($xmlfile); ksort($parsed); foreach ($parsed as $key => $value) { if (array_key_exists($key, $old_strings)) { $oldvalue = $old_strings[$key]; if ($oldvalue !== $value) { $tweaked[$key] = $oldvalue; } unset($old_strings[$key]); } } if (!($handle = fopen($langfile, 'w'))) { echo "*** Cannot write to {$langfile} !!\n"; continue; } echo " Modifying: {$lang}\n";