aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--langs.inc.php11
-rw-r--r--langs/diff.php2
-rw-r--r--langs/lib.php10
-rw-r--r--langs/report.php10
4 files changed, 24 insertions, 9 deletions
diff --git a/langs.inc.php b/langs.inc.php
index b06cfed04..da15b73d4 100644
--- a/langs.inc.php
+++ b/langs.inc.php
@@ -338,10 +338,11 @@ class i18n
* Get all locales from given file.
*
* @param string $file
+ * @param string $return_duplicates optional switch
*
* @return array
*/
- public static function _lang_return($file)
+ public static function _lang_return($file, $return_duplicates = false)
{
$strings = array();
@@ -356,9 +357,15 @@ class i18n
if ($C === ';' && !empty($f[$k+1])) {
$j = trim(substr($v, 1));
$j = str_replace(array("\'", "\""), array("'", '"'), $j);
+ if ($return_duplicates && !empty($strings[$j])) {
+ $duplicates[] = $j;
+ }
$strings[$j] = trim($f[$k+1]);
}
}
+ if (!empty($duplicates)) {
+ $strings['duplicates'] = $duplicates;
+ }
}
return $strings;
@@ -404,5 +411,3 @@ function _e($s = null, $args = null) { return i18n::_e($s, $args); }
function _h($s = null, $args = null, $tag = 'p') { return i18n::_h($s, $args, $tag); }
function _lang_load($locale, $domain) { return i18n::_lang_load($locale, $domain); }
-
-
diff --git a/langs/diff.php b/langs/diff.php
index d56be7f8e..68e741cd4 100644
--- a/langs/diff.php
+++ b/langs/diff.php
@@ -65,7 +65,7 @@ if($license) {
if($constitution || $license) {
$s .= 'Please read <a href="https://wiki.mageia.org/en/Internationalisation_Team_%28i18n%29#Special_cases_of_web_pages">page on wiki for more information</a> about that.</p>';
}
-foreach (array('missing' => 'missing strings', 'notrans' => 'untranslated strings', 'extra' => 'unused (old) strings') as $type => $name) {
+foreach (array('missing' => 'missing strings', 'notrans' => 'untranslated strings', 'extra' => 'unused (old) strings', 'dup_str' => 'duplicate strings') as $type => $name) {
if (count($diff[$type]) > 0) {
$s .= sprintf('<h2>%d %s:</h2>', count($diff[$type]), $name);
diff --git a/langs/lib.php b/langs/lib.php
index db1fc21f5..091883292 100644
--- a/langs/lib.php
+++ b/langs/lib.php
@@ -21,13 +21,14 @@ include '../langs.inc.php';
function _lang_diff($a, $b)
{
$fa = i18n::_lang_return($a);
- $fb = i18n::_lang_return($b);
+ $fb = i18n::_lang_return($b, true); // option to return duplicates
+ $duplicates = (isset($fb['duplicates']) ? array_pop($fb) : null);
- $ret = array(
+/* $ret = array(
'aCount' => count($fa),
'bCount' => count($fb),
'diff' => count($fa) - count($fb),
- );
+ ); unused var */
$missing = array();
$notrans = array();
@@ -53,7 +54,8 @@ function _lang_diff($a, $b)
'b' => count($fb),
'missing' => $missing,
'notrans' => $notrans,
- 'extra' => $extra
+ 'extra' => $extra,
+ 'dup_str' => $duplicates,
);
}
diff --git a/langs/report.php b/langs/report.php
index 9a3e6967a..05d002836 100644
--- a/langs/report.php
+++ b/langs/report.php
@@ -105,6 +105,7 @@
$test = _lang_diff($f, $langF);
$num_of_untranslated_strings = count($test['notrans']);
+ $num_of_duplicated_strings = count($test['dup_str']);
if ($link == 'about/constitution') {
$dest_constitution = sprintf('%s/%s/%s/%s_%s.md', APP_ROOT, $l, 'about/constitution', 'mageia.org_statutes', $l);
@@ -167,6 +168,9 @@
if (count($test['extra']) > 0) {
$extra = ' <span class="small">' . sprintf($diff_link, $f, $l) . '+' . count($test['extra']) . '</a></span>';
}
+ if ($num_of_duplicated_strings > 0) {
+ $extra .= ' <span class="small">' . sprintf($diff_link, $f, $l) . 'dup: ' . $num_of_duplicated_strings . '</a></span>';
+ }
$cols .= sprintf('<td class="ok"><a href="%s" title="get a copy of the file">OK</a>%s%s</td>',
$langF, $extra, $link);
@@ -192,7 +196,11 @@
$cols .= $num_of_untranslated_strings . '&nbsp;untranslated<br>';
}
if (count($test['extra']) > 0) {
- $cols .= count($test['extra']) . '&nbsp;extra';
+ $cols .= count($test['extra']) . '&nbsp;extra<br>';
+ }
+ if ($num_of_duplicated_strings > 0) {
+ $cols .= $num_of_duplicated_strings . '&nbsp;duplicate';
+ $cols .= ($num_of_duplicated_strings > 1 ? 's' : '');
}
$cols .= '</a>';
$cols .= $link . '</td>';