Permalink
Browse files

Updated L10n extractor

  • Loading branch information...
1 parent 8ffcde6 commit 176ce614957cde36c4dac3929ff3abdc132c872f @faceleg faceleg committed Aug 16, 2012
Showing with 16 additions and 5 deletions.
  1. +16 −5 src/plugins/i18n/extractor.php
@@ -85,7 +85,12 @@ function writeLocale($locale_file, $strings, $locale, $locale_name, $headerBlock
fwrite($locale_handle, $head);
foreach ($strings as $key => $value) {
- $output[] = $tab.'"'.str_replace('"', '\"', $key).'": "'.str_replace('"', '\"', $value).'"';
+ if ($value === false) {
+ $value = 'false';
+ } else {
+ $value = '"'.str_replace('"', '\"', $value).'"';
+ }
+ $output[] = $tab.'"'.str_replace('"', '\"', $key).'": '.$value;
}
fwrite($locale_handle, implode(",\n", $output));
@@ -114,12 +119,18 @@ function writeLocale($locale_file, $strings, $locale, $locale_name, $headerBlock
$headerBlock .= $line;
continue;
}
- $result= null;
- if(preg_match('/^\s*"(.+)":\s?"(.+)",?$/iU', $line, $result)) {
+ $result = null;
+ if(preg_match('/^\s*"(.+)":\s?(.+),?$/iU', $line, $result)) {
$headerCaptured = true;
$key = $result[1];
- $value = $result[2];
- if (isset($strings[$key]) && $strings[$key] != $value) {
+ $value = trim($result[2]);
+ $value = trim($value, '"');
+ if (!isset($strings[$key])){
+ continue;
+ }
+ if($value === 'false') {
+ $strings[$key] = false;
+ } else if (isset($strings[$key]) && $strings[$key] !== $value) {
$strings[$key] = $value;
}
}

0 comments on commit 176ce61

Please sign in to comment.