diff options
author | Filip Komar <filip@mageia.org> | 2014-01-12 21:32:30 +0000 |
---|---|---|
committer | Filip Komar <filip@mageia.org> | 2014-01-12 21:32:30 +0000 |
commit | 3a2f4b84559d12dcf2e73fdf97d14337876e069c (patch) | |
tree | a80aaaf51292c2ceee45892077f783185765198d /langs/lib.php | |
parent | 417e1cd2e0fbb4b231391f4b1b53a78ddbd889da (diff) | |
download | www-3a2f4b84559d12dcf2e73fdf97d14337876e069c.tar www-3a2f4b84559d12dcf2e73fdf97d14337876e069c.tar.gz www-3a2f4b84559d12dcf2e73fdf97d14337876e069c.tar.bz2 www-3a2f4b84559d12dcf2e73fdf97d14337876e069c.tar.xz www-3a2f4b84559d12dcf2e73fdf97d14337876e069c.zip |
l10n report can be limited to only one resource + better management of untranslated lines in constitution
Diffstat (limited to 'langs/lib.php')
-rw-r--r-- | langs/lib.php | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/langs/lib.php b/langs/lib.php index 091883292..f93e53777 100644 --- a/langs/lib.php +++ b/langs/lib.php @@ -122,4 +122,40 @@ function get_other_langs() } array_unshift($re, 'en'); return $re; -}
\ No newline at end of file +} + +function aproximate_number_of_untranslated_constitution_lines($app_root, $lang, $unique_lines_in_eng_constitution = array()) +{ + $constitution_is_readable = FALSE; + $dest_constitution = sprintf('%s/%s/%s/%s_%s.md', $app_root, $lang, 'about/constitution', 'mageia.org_statutes', $lang); + $number_of_unique_lines_in_eng_constitution = count($unique_lines_in_eng_constitution); + if(is_readable($dest_constitution)) { + $unique_lines_in_constitution = array_unique(file($dest_constitution)); + $number_of_unique_lines_in_constitution = count($unique_lines_in_constitution); + $constitution_is_readable = TRUE; + if ($lang == 'en') { + $aproximate_number_of_untranslated_lines = $number_of_unique_lines_in_constitution; + $untranslated_lines_in_constitution = array(); + } else { + $untranslated_lines_in_constitution = array_intersect($unique_lines_in_eng_constitution, $unique_lines_in_constitution); + $number_of_nonunique_lines_lang_constitution = count($untranslated_lines_in_constitution); + $ratio = $number_of_nonunique_lines_lang_constitution / $number_of_unique_lines_in_eng_constitution; + $limit_ratio = 0.15; // limit ratio of "allowed" untranslated lines + if ($ratio > $limit_ratio) { + // add aproximate number of untranslated constitution lines + $aproximate_number_of_untranslated_lines = $number_of_nonunique_lines_lang_constitution - round($limit_ratio * $number_of_unique_lines_in_eng_constitution); + } + } + } else { + $unique_lines_in_constitution = $unique_lines_in_eng_constitution; + $aproximate_number_of_untranslated_lines = $number_of_unique_lines_in_eng_constitution; + $untranslated_lines_in_constitution = $unique_lines_in_eng_constitution; + } + + return array( + 'unique_lines_in_constitution' => $unique_lines_in_constitution, + 'constitution_readable' => $constitution_is_readable, + 'untranslated_lines_in_constitution' => $untranslated_lines_in_constitution, + 'aproximate_number_of_untranslated_lines' => $aproximate_number_of_untranslated_lines, + ); +} |