diff --git a/scripts/lang_functions.php b/scripts/lang_functions.php index cd363ee48..38bd83b72 100644 --- a/scripts/lang_functions.php +++ b/scripts/lang_functions.php @@ -113,10 +113,17 @@ function add_langs_to_config($langs, $config) { $config['languages'] = json_decode( json_encode( $config['languages'] ), true ); ksort($config['languages']); $config['languages'] = json_decode( json_encode( $config['languages'] ), false ); - file_put_contents(CONFIG, json_encode($config, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); + save_json(CONFIG, $config); } } +/** + * Save json data. + */ +function save_json($path, $content) { + file_put_contents($path, str_replace('\/', '/', json_encode($content, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT))."\n"); +} + function get_langfolder($lang) { $folder = LANGPACKSFOLDER.'/'.str_replace('-', '_', $lang); if (!is_dir($folder) || !is_file($folder.'/langconfig.php')) { @@ -271,7 +278,7 @@ function build_lang($lang, $keys) { // Sort and save. ksort($translations); - file_put_contents(ASSETSPATH.$lang.'.json', str_replace('\/', '/', json_encode($translations, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT))); + save_json(ASSETSPATH.$lang.'.json', $translations); $success = count($translations); $percentage = floor($success/$total * 100); @@ -366,7 +373,7 @@ function save_key($key, $value, $filePath) { if (!isset($file[$key]) || $file[$key] != $value) { $file[$key] = $value; ksort($file); - file_put_contents($filePath, str_replace('\/', '/', json_encode($file, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT))); + save_json($filePath, $file); } } diff --git a/scripts/lang_functions.sh b/scripts/lang_functions.sh index 6b5b4ece3..2dc18ad05 100755 --- a/scripts/lang_functions.sh +++ b/scripts/lang_functions.sh @@ -124,6 +124,9 @@ function get_language { # Entry function to get all language files. function get_languages { suffix=$1 + if [ -z $suffix ]; then + suffix='' + fi get_last_version