$sections = get_files($exportDir . $language . '/', ''); //print_r($sections); foreach ($sections as $section) { echo "read section: {$section}\n"; $lang = array(); require_once $exportDir . $language . '/' . $section; //print_r($lang); foreach ($lang as $i8ln_key => $i8ln_value) { $section = str_replace('.php', '', $section); //$translations[$language][$section][$i8ln_key] = $i8ln_value; $translations[$section][$language][$i8ln_key] = $i8ln_value; } } } //print_r($translations); generate_nls($translations); /* input: - translations/de/aloha.php - translations/de/plugin.format.php (new) - translations/de/Com.gentics.aloha.plugins.Format.php (old) $lang['floatingmenu.tab.insert'] = 'Einfügen'; $lang['yes'] = 'Ja'; output: - lib/aloha/nls/de/il8n.js - plugins/common/format/nls/de/il8n.js (de) - plugins/common/format/nls/il8n.js (master - en) master file: define( { 'root': { 'floatingmenu.tab.insert': 'Insert',
} } } } $full_translated = array(); foreach ($translation_status as $lang => $status) { //echo $lang . ' - ' . $status['translated'] . '/' . $status['total'] . ' -- ' . ($status['total'] - $status['translated']). "\n"; if ($status['total'] - $status['translated'] == 0) { $full_translated[] = $lang; } } // when importing one specific language reset the full_translated check if (count($export_translation) == 1) { $full_translated = array_merge($full_translated, $export_translation); } generate_nls($translations, $full_translated, $export_translation); function generate_nls($translations, $full_translated, $export_translation) { $exportDir = './nls/'; foreach ($translations as $section => $language_data) { echo "\n\n*** generate {$section}\n"; $out = "define({\n"; $out .= "\t\"root\": {\n"; if (!empty($language_data['en'])) { // in case you just import a specific language don't rewrite the master file $master = $language_data['en']; unset($language_data['en']); $available_languages = array_keys($language_data); foreach ($master as $translate_key => $translate_string) { if (!empty($translate_key)) { //$translate_string = htmlentities($translate_string, ENT_SUBSTITUTE); // needs php 5.4