aboutsummaryrefslogtreecommitdiffstats
path: root/langs/lib.php
diff options
context:
space:
mode:
authorfilip <filip.komar@gmail.com>2014-12-19 11:18:27 +0100
committerfilip <filip.komar@gmail.com>2014-12-19 11:18:27 +0100
commit75fe653c2c76e51bd51833361bc89d845fc4c0a1 (patch)
tree646524392c0836c930b900363439a735f67ffa19 /langs/lib.php
parentc217d01c59874a2c181baf185b1cdc8d05dd292b (diff)
downloadwww-75fe653c2c76e51bd51833361bc89d845fc4c0a1.tar
www-75fe653c2c76e51bd51833361bc89d845fc4c0a1.tar.gz
www-75fe653c2c76e51bd51833361bc89d845fc4c0a1.tar.bz2
www-75fe653c2c76e51bd51833361bc89d845fc4c0a1.tar.xz
www-75fe653c2c76e51bd51833361bc89d845fc4c0a1.zip
report about differences between Transifex and our git repository for documentation added
Diffstat (limited to 'langs/lib.php')
-rw-r--r--langs/lib.php47
1 files changed, 32 insertions, 15 deletions
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(),
);
}