From cb94dcd2a52efebff7267c4be62bda4d82ca15cd Mon Sep 17 00:00:00 2001 From: Jorge Glez Date: Tue, 8 Oct 2013 23:07:58 +0200 Subject: [PATCH 1/3] Replaced the line cunt during script execution with a handsome looking diff of added/removed keys --- localizationTextsParse.php | 59 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 3 deletions(-) diff --git a/localizationTextsParse.php b/localizationTextsParse.php index 0f61612..70bffcd 100644 --- a/localizationTextsParse.php +++ b/localizationTextsParse.php @@ -42,6 +42,18 @@ $argv[3] = '111'; } +/* + +argv 4 is a generic cache directory for storing diffs +it's optional but reccommended + +*/ +if (!$argv[4]) +{ + $argv[4] = false; +} + + @@ -52,6 +64,7 @@ $iOSFiles = array(); $androidFiles = array(); +$keys = array(); if (count($localizationFileLines) > 0) { @@ -81,7 +94,7 @@ if (!$lineIsAComment && strlen($key) > 0) // It's not a comment and it's not empty { - echo $key,','; + $keys[] = $key; $lines++; $languageIndex = 0; @@ -119,8 +132,8 @@ } echo "\n".$outputDivider."\n"; - echo "Lines: ".count($localizationFileLines); - echo "\n".$outputDivider."\n\n"; + echo compareDiff($argv[4],$keys); + echo $outputDivider."\n\n"; if($argv[3][0] == '1') { writeIOSFiles($iOSFiles, $destPath); @@ -319,3 +332,43 @@ function convertLanguageToISO639($language) { return $languages[$language]; } + +function compareDiff($path,$keys) { + + global $outputDivider; + + $original = json_decode(file_get_contents($path.'localizationTextsParse/strings.pack')); + $added = array(); + $removed = array(); + + foreach($original as $key) { + if(!in_array($key, $keys)) { + $removed[] = $key; + } + } + foreach($keys as $key) { + if(!in_array($key, $original)) { + $added[] = $key; + } + } + + if($added[0]) { + echo '[+] '.implode(',', $added)."\n"; + } + if($removed[0]) { + echo '[-] '.implode(',', $removed)."\n"; + } + + if(!$added[0] && !$removed[0]) { + echo '[x] no key changes'."\n"; + } + + echo '[ยท] '.count($keys). ' total keys'."\n"; + + createPathIfDoesntExists($path.'localizationTextsParse/a.file'); + $pack = fopen($path.'localizationTextsParse/strings.pack', "w+"); + if ($pack !== FALSE) { + fwrite($pack,json_encode($keys)); + } else {} + +} From 748f6c258663be1fe244e0c51d59a977f0d415c6 Mon Sep 17 00:00:00 2001 From: Jorge Glez Date: Tue, 8 Oct 2013 23:08:43 +0200 Subject: [PATCH 2/3] Galician language support --- localizationTextsParse.php | 1 + 1 file changed, 1 insertion(+) diff --git a/localizationTextsParse.php b/localizationTextsParse.php index 70bffcd..2b24e04 100644 --- a/localizationTextsParse.php +++ b/localizationTextsParse.php @@ -329,6 +329,7 @@ function convertLanguageToISO639($language) { $languages['Portuguese'] = "pt"; $languages['Dutch'] = "nl"; $languages['Swedish'] = "sv"; + $languages['Gallego'] = "gl"; return $languages[$language]; } From e97047b6628ee438d7ee61845d1410bd5cb35ea1 Mon Sep 17 00:00:00 2001 From: Jorge Glez Date: Tue, 8 Oct 2013 23:12:53 +0200 Subject: [PATCH 3/3] renamed JSON output --- localizationTextsParse.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/localizationTextsParse.php b/localizationTextsParse.php index 2b24e04..b8641ea 100644 --- a/localizationTextsParse.php +++ b/localizationTextsParse.php @@ -293,7 +293,8 @@ function writeAndroidFiles($files) function writeJSONFiles($files,$destPath) { - $filename = $destPath.'/stringsFromApp.json'; + $filename = $destPath.'/strings.json'; + echo("JSON - Trying to Write:\n".$filename."\n"); createPathIfDoesntExists($filename);