diff options
-rw-r--r-- | en/about/license/index.php | 30 | ||||
-rw-r--r-- | en/about/license/php-mo.php | 31 |
2 files changed, 27 insertions, 34 deletions
diff --git a/en/about/license/index.php b/en/about/license/index.php index d5d59ccbc..a530336fb 100644 --- a/en/about/license/index.php +++ b/en/about/license/index.php @@ -2,23 +2,20 @@ define('HLANG', true); require '../../../langs.php'; -//$locale = 'sl'; // qq debug + _lang_load($locale, 'about/license'); require('php-mo.php'); -if($locale == 'en') { // this can be done better maybe with preg_replace strtoupper combo +if($locale == 'en') { $po_locale = 'libDrakX.pot'; -} else if($locale == 'pa-in') { - $po_locale = 'pa_IN.po'; -} else if($locale == 'pt-br') { - $po_locale = 'pt_BR.po'; -} else if($locale == 'zh-cn') { - $po_locale = 'zh_CN.po'; -} else if($locale == 'zh-tw') { - $po_locale = 'zh_TW.po'; } else { - $po_locale = "$locale.po"; + preg_match("/(..)(-)(..)/", $locale, $parsed_locale); + if(isset($parsed_locale[3])) { // create pt_BR.po from pt-br and alike + $po_locale = $parsed_locale[1] . '_' . strtoupper($parsed_locale[3]) . '.po'; + } else { + $po_locale = $locale . '.po'; + } } //$po_files_path = "../../../../drakx_share/"; // qq debug @@ -28,13 +25,8 @@ $po_files_end = "?view=co"; $po_file = phpmo_parse_po_file($po_files_path . $po_locale . $po_files_end); if($po_file === false) { -// echo "ERROR loading " . $po_files_path . $po_locale . $po_files_end; // qq debug $po_file = phpmo_parse_po_file($po_files_path . "libDrakX.pot" . $po_files_end); } -if($po_file === false) { -// echo "ERROR loading " . $po_files_path . "libDrakX.pot" . $po_files_end; // qq debug -} -//var_dump($po_file); // qq debug $license_strings = array( array('_: You can warn about unofficial translation here'), @@ -75,10 +67,10 @@ if($locale == 'en') { array_shift($license_strings); } echo '<div id="preamble">'; _h('An introduction text ... (summarizing, explaining the core principles, and why this license was chosen).'); echo '<p>' . sprintf(_t('See also %swiki page about licensing policy</a>.'), - '<a href="https://wiki.mageia.org/en/Licensing_policy">') . '</p></div>'; + '<a href="https://wiki.mageia.org/en/Licensing_policy">') . '</p></div><br>'; _h('Mageia license', null, 'h2'); - $search = array('\\"','\n\n', '\n', ' '); - $replace = array('"','<br>', ' ', ' '); + $search = array('\\"', '\n', ' '); + $replace = array('"','<br>', ' '); foreach($license_strings as $value) { $license_string = ''; if(isset($po_file[$value[0]]["msgstr"][0])) { diff --git a/en/about/license/php-mo.php b/en/about/license/php-mo.php index 4d5489ca2..6e2159a25 100644 --- a/en/about/license/php-mo.php +++ b/en/about/license/php-mo.php @@ -69,21 +69,26 @@ function phpmo_parse_po_file($in) { // state $state = null; $fuzzy = false; - $num = 0; // qq // iterate over lines while(($line = fgets($fh, 65536)) !== false) { - $num++; // qq $line = trim($line); - if ($line === '') + if ($line === '') { + // save stored entry on empty line + // block moved to fix "fuzzy flag first line" bug which didn't saved previous proper string at all + if (sizeof($temp) && array_key_exists('msgid', $temp) && array_key_exists('msgstr', $temp)) { + if (!$fuzzy) + $hash[] = $temp; + $temp = array (); + $state = null; + $fuzzy = false; + } continue; - + } $array_of_splited_string = preg_split('/\s/', $line, 2); $key = $array_of_splited_string[0]; $data = (isset($array_of_splited_string[1]) ? $array_of_splited_string[1] : ''); -// echo PHP_EOL . ' $key: ' . $key . ' ' . PHP_EOL . '$data: ' . $data . ' ' . PHP_EOL . '$line: ' . $line . PHP_EOL; - switch ($key) { case '#,' : // flag... $fuzzy = in_array('fuzzy', preg_split('/,\s*/', $data)); @@ -91,14 +96,11 @@ function phpmo_parse_po_file($in) { case '#.' : // extracted-comments case '#:' : // reference... case '#|' : // msgid previous-untranslated-string - // start a new entry - if (sizeof($temp) && array_key_exists('msgid', $temp) && array_key_exists('msgstr', $temp)) { - if (!$fuzzy) - $hash[] = $temp; - $temp = array (); - $state = null; - $fuzzy = false; - } + break; + case '#~' : // commented-unused-string + $temp = array (); + $state = null; + $fuzzy = false; break; case 'msgctxt' : // context @@ -133,7 +135,6 @@ function phpmo_parse_po_file($in) { default : // parse error fclose($fh); - echo ' $line: ' . $line . ' $key: ' . $key . ' $num: ' . $num . ' $data: ' . $data . ' $state: ' . $state . ' '; // qq return FALSE; } } |