aboutsummaryrefslogtreecommitdiffstats
path: root/langs/lib.php
diff options
context:
space:
mode:
authorfilip <filip.komar@gmail.com>2014-12-23 10:54:17 +0100
committerfilip <filip.komar@gmail.com>2014-12-23 10:54:17 +0100
commitb5084d09d4f180ed8bf7481a860c20e1cab0ae0f (patch)
tree93df024fbe2366d62e7a9a75ed46408af5812cfa /langs/lib.php
parente1c6d13ee94d5f989ba9c5e9e28f50a0f172174d (diff)
downloadwww-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/lib.php')
-rw-r--r--langs/lib.php20
1 files changed, 13 insertions, 7 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(),