Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 59 additions & 4 deletions localizationTextsParse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}





Expand All @@ -52,6 +64,7 @@

$iOSFiles = array();
$androidFiles = array();
$keys = array();

if (count($localizationFileLines) > 0)
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -280,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);

Expand Down Expand Up @@ -316,6 +330,47 @@ function convertLanguageToISO639($language) {
$languages['Portuguese'] = "pt";
$languages['Dutch'] = "nl";
$languages['Swedish'] = "sv";
$languages['Gallego'] = "gl";
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Esto no sé cuando sucedió


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 {}

}