Merge pull request #56 from TouchInstinct/fix/multiLang

Base language substitution added
This commit is contained in:
Alexey Gerasimov 2018-04-23 23:16:36 +03:00 committed by GitHub
commit 622b2d3450
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -10,18 +10,21 @@
$localization = './'.$PROJECT_NAME.'/Resources/Localization/';
$baseFile = file_get_contents(array_pop(glob($COMMON_STRINGS_PATH.'/default*.json')));
$baseJson = json_decode($baseFile, true);
foreach (glob($COMMON_STRINGS_PATH.'/*.json') as $file) {
$languageName = array_pop(explode('_', basename($file, '.json')));
$isBase = strpos($file, 'default') !== false;
$jsonFile = file_get_contents($file);
$json = json_decode($jsonFile);
$json = array_merge($baseJson, json_decode($jsonFile, true));
$ios_strings = "";
foreach ($json as $key=>$value) {
$ios_strings.='"'.$key.'" = "'.str_replace('%s', '%@', str_replace('"','\"', str_replace("\n", '\n', $value))).'";'.PHP_EOL;
}
$ios_strings = preg_replace('/(\\\\)(u)(\d{4})/', '$1U$3', $ios_strings);
$ios_strings = preg_replace('/(\\\\)(u)([0-9a-fA-F]{4})/', '$1U$3', $ios_strings);
$lproj = $localization.$languageName.'.lproj/';
createFolder($lproj);