Skip to content
Extraits de code Groupes Projets
Valider 5dba66bc rédigé par sgiehl's avatar sgiehl
Parcourir les fichiers

refs #4086 fixed translationwriter to work with json files

parent 740854c5
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -86,7 +86,7 @@ class TranslationWriter ...@@ -86,7 +86,7 @@ class TranslationWriter
/** /**
* Output translations to string * Output translations to string
* *
* @param array $translations Array of translations ( key => translated string ) * @param array $translations multidimensional Array of translations ( plugin => array (key => translated string ) )
* @return string * @return string
*/ */
static public function outputTranslation($translations) static public function outputTranslation($translations)
...@@ -96,33 +96,18 @@ class TranslationWriter ...@@ -96,33 +96,18 @@ class TranslationWriter
} }
$en = self::$baseTranslation; $en = self::$baseTranslation;
$output = array('<?php', '$translations = array('); $cleanedTranslations = array();
$deferoutput = array();
/* write all the translations that exist in en.php */
foreach ($en as $key => $en_translation) {
if (isset($translations[$key]) && !empty($translations[$key])) {
$tmp = self::quote($translations[$key]);
$output[] = "\t'$key' => $tmp,";
}
}
/* write the remaining translations (that don't exist in en.php) */ // filter out all translations that don't exist in english translations
foreach ($translations as $key => $translation) { foreach ($en AS $plugin => $enTranslations) {
if (!isset($en[$key]) && !empty($translation)) { foreach ($enTranslations as $key => $en_translation) {
$tmp = self::quote($translation); if (isset($translations[$plugin][$key]) && !empty($translations[$plugin][$key])) {
$deferoutput[] = "\t'$key' => $tmp,"; $cleanedTranslations[$plugin][$key] = $translations[$plugin][$key];
}
} }
} }
if (count($deferoutput) > 0) { return json_encode($cleanedTranslations, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
$output[] = "\n\t// FOR REVIEW";
$output = array_merge($output, $deferoutput);
}
$output[] = ');';
return implode($output, "\n") . "\n";
} }
/** /**
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter