MOBILE-3833 lang: Improve language scripts
parent
7cc309275c
commit
347d08f806
|
@ -113,10 +113,17 @@ function add_langs_to_config($langs, $config) {
|
||||||
$config['languages'] = json_decode( json_encode( $config['languages'] ), true );
|
$config['languages'] = json_decode( json_encode( $config['languages'] ), true );
|
||||||
ksort($config['languages']);
|
ksort($config['languages']);
|
||||||
$config['languages'] = json_decode( json_encode( $config['languages'] ), false );
|
$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) {
|
function get_langfolder($lang) {
|
||||||
$folder = LANGPACKSFOLDER.'/'.str_replace('-', '_', $lang);
|
$folder = LANGPACKSFOLDER.'/'.str_replace('-', '_', $lang);
|
||||||
if (!is_dir($folder) || !is_file($folder.'/langconfig.php')) {
|
if (!is_dir($folder) || !is_file($folder.'/langconfig.php')) {
|
||||||
|
@ -271,7 +278,7 @@ function build_lang($lang, $keys) {
|
||||||
|
|
||||||
// Sort and save.
|
// Sort and save.
|
||||||
ksort($translations);
|
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);
|
$success = count($translations);
|
||||||
$percentage = floor($success/$total * 100);
|
$percentage = floor($success/$total * 100);
|
||||||
|
@ -366,7 +373,7 @@ function save_key($key, $value, $filePath) {
|
||||||
if (!isset($file[$key]) || $file[$key] != $value) {
|
if (!isset($file[$key]) || $file[$key] != $value) {
|
||||||
$file[$key] = $value;
|
$file[$key] = $value;
|
||||||
ksort($file);
|
ksort($file);
|
||||||
file_put_contents($filePath, str_replace('\/', '/', json_encode($file, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)));
|
save_json($filePath, $file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -124,6 +124,9 @@ function get_language {
|
||||||
# Entry function to get all language files.
|
# Entry function to get all language files.
|
||||||
function get_languages {
|
function get_languages {
|
||||||
suffix=$1
|
suffix=$1
|
||||||
|
if [ -z $suffix ]; then
|
||||||
|
suffix=''
|
||||||
|
fi
|
||||||
|
|
||||||
get_last_version
|
get_last_version
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue