From b5084d09d4f180ed8bf7481a860c20e1cab0ae0f Mon Sep 17 00:00:00 2001 From: filip Date: Tue, 23 Dec 2014 10:54:17 +0100 Subject: speed improvement for differences between Tx and our git report --- langs/lib.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'langs/lib.php') 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(), -- cgit v1.2.1