Esempio n. 1
0
 $xmllang = str_replace('_utf8', '', $lang);
 if (array_key_exists($xmllang, $langconversion)) {
     $xmllang = $langconversion[$xmllang];
     if (empty($xmllang)) {
         echo "         Ignoring: {$lang}\n";
         continue;
     }
 }
 $xmlfile = "{$tempdir}/{$xmllang}.xml";
 if (!file_exists($xmlfile)) {
     echo "         Skipping: {$lang}\n";
     continue;
 }
 $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) {
Esempio n. 2
0
foreach ($old_strings as $key => $value) {
    fwrite($handle, editor_tinymce_encode_stringline($key, $value));
}
fwrite($handle, "\n\n// == TinyMCE upstream lang strings from all standard upstream plugins ==\n");
foreach ($parsed as $key => $value) {
    fwrite($handle, editor_tinymce_encode_stringline($key, $value));
}
if ($tweaked) {
    fwrite($handle, "\n\n// == Our modifications or upstream changes ==\n");
    foreach ($tweaked as $key => $value) {
        fwrite($handle, editor_tinymce_encode_stringline($key, $value));
    }
}
fclose($handle);
// Now update all other langs.
$en_strings = editor_tinymce_get_all_strings('en');
if (!file_exists($targetlangdir)) {
    echo "Can not find target lang dir: {$targetlangdir} !!";
}
$xmlfiles = new DirectoryIterator($tempdir);
foreach ($xmlfiles as $xmlfile) {
    if ($xmlfile->isDot() or $xmlfile->isLink() or $xmlfile->isDir()) {
        continue;
    }
    $filename = $xmlfile->getFilename();
    if ($filename == 'en.xml') {
        continue;
    }
    if (substr($filename, -4) !== '.xml') {
        continue;
    }
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * This script imports TinyMCE lang strings into Moodle English lang pack.
 *
 * @package    editor_tinymce
 * @copyright  2009 Petr Skoda (http://skodak.org)
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
define('CLI_SCRIPT', true);
require __DIR__ . '/../../../../config.php';
if (!debugging('', DEBUG_DEVELOPER)) {
    die('Only for developers!!!!!');
}
// Current strings in our lang pack.
$old_strings = editor_tinymce_get_all_strings();
ksort($old_strings);
// Upstream strings.
$parsed = editor_tinymce_parse_js_files();
ksort($parsed);
// Our modifications and upstream changes in existing strings.
$tweaked = array();
// Detect changes and new additions - ignore case difference, no UTF-8 here.
foreach ($parsed as $key => $value) {
    if (array_key_exists($key, $old_strings)) {
        $oldvalue = $old_strings[$key];
        if (strtolower($oldvalue) === strtolower($value)) {
            $parsed[$key] = $oldvalue;
        } else {
            $tweaked[$key] = $oldvalue;
        }