From 7321c3a6f3f3c949c54bd673b58508972c5e7bb9 Mon Sep 17 00:00:00 2001 From: realsnake Date: Wed, 28 Aug 2013 14:36:26 +0800 Subject: [PATCH 1/2] Support Chinese. --- UpdateCodeStrings.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/UpdateCodeStrings.sh b/UpdateCodeStrings.sh index 7422ac6..8babc62 100755 --- a/UpdateCodeStrings.sh +++ b/UpdateCodeStrings.sh @@ -40,7 +40,7 @@ else find . -type f -name "*.m*" -print > listOfFiles.txt - cat listOfFiles.txt |tr '\n' '\0' |xargs -0 grep -o "NSLocalizedString(@\"[[:alnum:]]*\", @\"[a-zA-Z0-9 !@#\$%\^&\*()\.,-\+']*\")" > output.txt + cat listOfFiles.txt |tr '\n' '\0' |xargs -0 grep -o "NSLocalizedString(@\".*\", @\".*\")" > output.txt # Next, get all locale strings folders. If Localizable.strings found, append to existing file; otherwise, create a new one. @@ -74,19 +74,21 @@ else while read LINE do - foundLocalizedString=$(echo "$LINE" | grep -o "NSLocalizedString(@\"[[:alnum:]]*\", @\"[a-zA-Z0-9 !@#\$%\^&\*()\.,-\+']*\")") + foundLocalizedString=$(echo "$LINE" | grep -o "NSLocalizedString(@\".*\", @\".*\")") - foundKey=$(echo "$foundLocalizedString" | grep -o "(@\"[[:alnum:]]*\"") - keyStart="\"" - finalKey=$(echo "$foundKey" | grep -o "$keyStart.*") + foundKey=$(echo "$foundLocalizedString" | grep -o "(@\".*\"\(,\|, *\)") - $(grep -q "$finalKey" $stringsFile) + keyStart="\"" + finalKey=$(echo "$foundKey" | grep -o "$keyStart[^,]*") + + $(grep -q "$finalKey" $stringsFile) if [ $? -eq 1 ]; then echo "****** key is New: $finalKey" - foundComment=$(echo "$foundLocalizedString" | grep -o "@\"[a-zA-Z0-9 !@#\$%\^&\*()\.,-\+']*\")") - commentStart="\"" + foundComment=$(echo "$foundLocalizedString" | grep -o "\(,\|, *\)@\".*\")") + + commentStart="\"" intermediateComment=$(echo "$foundComment" | grep -o "$commentStart.*") finalComment=$(echo "$intermediateComment" | sed "s/)//") From 33a05fd4bdb9c5cc7fed53565565849c7f7ece92 Mon Sep 17 00:00:00 2001 From: realsnake Date: Wed, 28 Aug 2013 14:54:09 +0800 Subject: [PATCH 2/2] Support Chinese. --- UpdateCodeStrings.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UpdateCodeStrings.sh b/UpdateCodeStrings.sh index 8babc62..509567a 100755 --- a/UpdateCodeStrings.sh +++ b/UpdateCodeStrings.sh @@ -40,7 +40,7 @@ else find . -type f -name "*.m*" -print > listOfFiles.txt - cat listOfFiles.txt |tr '\n' '\0' |xargs -0 grep -o "NSLocalizedString(@\".*\", @\".*\")" > output.txt + cat listOfFiles.txt |tr '\n' '\0' |xargs -0 grep -o "NSLocalizedString(@\".*\"\(,\|, *\)@\".*\")" > output.txt # Next, get all locale strings folders. If Localizable.strings found, append to existing file; otherwise, create a new one. @@ -74,7 +74,7 @@ else while read LINE do - foundLocalizedString=$(echo "$LINE" | grep -o "NSLocalizedString(@\".*\", @\".*\")") + foundLocalizedString=$(echo "$LINE" | grep -o "NSLocalizedString(@\".*\"\(,\|, *\)@\".*\")") foundKey=$(echo "$foundLocalizedString" | grep -o "(@\".*\"\(,\|, *\)")