From 75fe653c2c76e51bd51833361bc89d845fc4c0a1 Mon Sep 17 00:00:00 2001 From: filip Date: Fri, 19 Dec 2014 11:18:27 +0100 Subject: report about differences between Transifex and our git repository for documentation added --- langs/lib.php | 47 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 15 deletions(-) (limited to 'langs/lib.php') diff --git a/langs/lib.php b/langs/lib.php index 03520e317..3b68db368 100644 --- a/langs/lib.php +++ b/langs/lib.php @@ -81,24 +81,40 @@ function _lang_diff($a, $b) * * @return array */ -function _po_diff($locale, $resource) +function _po_diff($locale, $resource, $path = NULL) { - $source_l = read_translation_file('en', $resource); - $target_l = read_translation_file($locale, $resource); + if (is_null($path)) { + $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 ('en' == $locale) { + $target_l = $source_l; + } else { + $locale = locale_hyphen_underscore($locale, true); + $target_path_filename = sprintf('%s/%s.po', $path, $locale); + $target_l = phpmo_parse_po_file($target_path_filename); + } + } $pot_strings = array(); $untrans = array(); $fuzzy_or_missing = array(); - foreach ($source_l as $escaped_string => $subarray) { - if (!empty($subarray["msgid"])) { // filter out header - $pot_strings[$escaped_string] = $subarray["msgid"]; + if ($source_l != FALSE) { + foreach ($source_l as $escaped_string => $subarray) { + if (!empty($subarray["msgid"])) { // filter out header + $pot_strings[$escaped_string] = $subarray["msgid"]; + } } } - foreach ($target_l as $escaped_string => $subarray) { - if (!empty($subarray["msgid"])) { // filter out header - $po_strings[$escaped_string] = $subarray["msgstr"][0]; + if ($target_l != FALSE) { + foreach ($target_l as $escaped_string => $subarray) { + if (!empty($subarray["msgid"])) { // filter out header + $po_strings[$escaped_string] = $subarray["msgstr"][0]; + } } } @@ -113,12 +129,13 @@ function _po_diff($locale, $resource) } return array( - 'a' => count($pot_strings), // # of original strings -// 'b' => count($po_strings), // # of target strings - 'fuzzy_or_missing' => $fuzzy_or_missing, - 'notrans' => $untrans, - 'extra' => array(), - 'dup_str' => array(), + 'a' => count($pot_strings), // # of original strings +// 'b' => count($po_strings), // # of target strings +// 'source_strings' => $pot_strings, // array of original strings + 'fuzzy_or_missing' => $fuzzy_or_missing, // array of fuzzy or missing strings + 'notrans' => $untrans, // array of untranslated strings + 'extra' => array(), + 'dup_str' => array(), ); } -- cgit v1.2.1