diff options
author | filip <filip.komar@gmail.com> | 2014-12-23 10:54:17 +0100 |
---|---|---|
committer | filip <filip.komar@gmail.com> | 2014-12-23 10:54:17 +0100 |
commit | b5084d09d4f180ed8bf7481a860c20e1cab0ae0f (patch) | |
tree | 93df024fbe2366d62e7a9a75ed46408af5812cfa /langs | |
parent | e1c6d13ee94d5f989ba9c5e9e28f50a0f172174d (diff) | |
download | www-b5084d09d4f180ed8bf7481a860c20e1cab0ae0f.tar www-b5084d09d4f180ed8bf7481a860c20e1cab0ae0f.tar.gz www-b5084d09d4f180ed8bf7481a860c20e1cab0ae0f.tar.bz2 www-b5084d09d4f180ed8bf7481a860c20e1cab0ae0f.tar.xz www-b5084d09d4f180ed8bf7481a860c20e1cab0ae0f.zip |
speed improvement for differences between Tx and our git report
Diffstat (limited to 'langs')
-rw-r--r-- | langs/lib.php | 20 | ||||
-rw-r--r-- | langs/report_tx_git.php | 13 |
2 files changed, 20 insertions, 13 deletions
diff --git a/langs/lib.php b/langs/lib.php index 3b68db368..42183c027 100644 --- a/langs/lib.php +++ b/langs/lib.php @@ -78,17 +78,23 @@ function _lang_diff($a, $b) * * @param string $locale locale name ('sl') * @param string $resource file name ('about/license') + * @param array $source_l array with source file strings (to avoid duplicated parsing) + * @param string $path directly passed path for nonlocal files * * @return array */ -function _po_diff($locale, $resource, $path = NULL) +function _po_diff($locale, $resource, $source_l = NULL, $path = NULL) { if (is_null($path)) { - $source_l = read_translation_file('en', $resource); + if (NULL == $source_l) { + $source_l = read_translation_file('en', $resource); + } $target_l = read_translation_file($locale, $resource); } else { - $source_path_filename = sprintf('%s/%s.pot', $path, $resource); - $source_l = phpmo_parse_po_file($source_path_filename); + if (NULL == $source_l) { + $source_path_filename = sprintf('%s/%s.pot', $path, $resource); + $source_l = phpmo_parse_po_file($source_path_filename); + } if ('en' == $locale) { $target_l = $source_l; } else { @@ -102,7 +108,7 @@ function _po_diff($locale, $resource, $path = NULL) $untrans = array(); $fuzzy_or_missing = array(); - if ($source_l != FALSE) { + if (FALSE != $source_l) { foreach ($source_l as $escaped_string => $subarray) { if (!empty($subarray["msgid"])) { // filter out header $pot_strings[$escaped_string] = $subarray["msgid"]; @@ -110,7 +116,7 @@ function _po_diff($locale, $resource, $path = NULL) } } - if ($target_l != FALSE) { + if (FALSE != $target_l) { foreach ($target_l as $escaped_string => $subarray) { if (!empty($subarray["msgid"])) { // filter out header $po_strings[$escaped_string] = $subarray["msgstr"][0]; @@ -131,7 +137,7 @@ function _po_diff($locale, $resource, $path = NULL) return array( 'a' => count($pot_strings), // # of original strings // 'b' => count($po_strings), // # of target strings -// 'source_strings' => $pot_strings, // array of original strings + 'source_strings' => $source_l, // array of original strings 'fuzzy_or_missing' => $fuzzy_or_missing, // array of fuzzy or missing strings 'notrans' => $untrans, // array of untranslated strings 'extra' => array(), diff --git a/langs/report_tx_git.php b/langs/report_tx_git.php index dc4f5e8bb..a305142f3 100644 --- a/langs/report_tx_git.php +++ b/langs/report_tx_git.php @@ -140,8 +140,9 @@ function build_links($git_resource_name, $language_code, $resource_type, $stat_d function generating_report($language_codes, $resource_names, $path = NULL, $pot_name = NULL) { $report = array(); - foreach ($language_codes as $l) { - foreach ($resource_names as $f) { + foreach ($resource_names as $f) { + $source_strings = NULL; + foreach ($language_codes as $l) { $references = ''; if (is_null($pot_name)) { $resource = _extract_resource($f); @@ -153,14 +154,14 @@ function generating_report($language_codes, $resource_names, $path = NULL, $pot_ $langF = '../_nav/langs/' . $l . '.po' . (($l == 'en') ? 't' : ''); } if (!is_null($path) || file_exists($langF)) { - $stat = _po_diff($l, $resource, $path); + $stat = _po_diff($l, $resource, $source_strings, $path); $num_of_fuzzy_or_missing = count($stat['fuzzy_or_missing']); - $num_of_untranslated = count($stat['notrans']); } else { // file $langF doesn't exists in 'Webpages' $resource_type - $stat = _po_diff('en', $resource); + $stat = _po_diff('en', $resource, $source_strings); $num_of_fuzzy_or_missing = 0; - $num_of_untranslated = count($stat['notrans']); } + $num_of_untranslated = count($stat['notrans']); + $source_strings = $stat['source_strings']; // unify resource names, navigation is a special exception $resource_name = str_replace(array('../_nav/langs/en', 'en/', '.pot'), array('nav', '', ''), $f); // create pt_BR from pt-br and alike to unify languages |