Merge pull request #120 from TouchInstinct/feature/addConfiguresForLocalization

Feature/add configures for localization
This commit is contained in:
Sergey 2019-06-26 19:44:13 +03:00 committed by GitHub
commit 745c70243e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -33,8 +33,7 @@
if($isBase) {
createFolder($localization.'Base.lproj/');
file_put_contents($localization.'Base.lproj/Localizable.strings', $ios_strings);
$ios_swift_strings = 'import Foundation'.PHP_EOL.
'import LeadKit'.PHP_EOL.PHP_EOL.
$ios_swift_strings = 'import Foundation'.PHP_EOL.PHP_EOL.
'// swiftlint:disable superfluous_disable_command'.PHP_EOL.
'// swiftlint:disable line_length'.PHP_EOL.
'// swiftlint:disable file_length'.PHP_EOL.
@ -42,7 +41,7 @@
'extension String {'.PHP_EOL;
foreach ($json as $key=>$value) {
$value_without_linefeed = preg_replace("/\r|\n/", " ", $value);
$ios_swift_strings .= "\t/// ".$value_without_linefeed."\n\t".'static let '.preg_replace_callback('/_(.?)/', function ($m) { return strtoupper($m[1]); }, $key).' = "'.$key.'".localized()'."\n".PHP_EOL;
$ios_swift_strings .= "\t/// ".$value_without_linefeed."\n\t".'static let '.preg_replace_callback('/_(.?)/', function ($m) { return strtoupper($m[1]); }, $key).' = NSLocalizedString("'.$key.'", comment: "")'."\n".PHP_EOL;
}
$ios_swift_strings .= '}'.PHP_EOL;
file_put_contents($localization.'String+Localization.swift', $ios_swift_strings);

View File

@ -1,5 +1,6 @@
LOCALIZATION_PATH="${PROJECT_NAME}/Resources/Localization"
STRINGS_FOLDER="common/strings"
#first argument set strings folder path
STRINGS_FOLDER=${1:-"common/strings"}
if ! [ -e ${LOCALIZATION_PATH} ]; then
echo "${PROJECT_DIR}/${LOCALIZATION_PATH} path does not exist. Add these folders and try again."
@ -11,4 +12,5 @@ if ! [ -e "${PROJECT_DIR}/${STRINGS_FOLDER}" ]; then
exit 1
fi
php build-scripts/xcode/aux_scripts/import_strings.php ${PROJECT_NAME} ${STRINGS_FOLDER}
#second argument set strings script path
php ${2:-build-scripts/xcode/aux_scripts/import_strings.php} ${PROJECT_NAME} ${STRINGS_FOLDER}