diff options
author | Filip Komar <filip@mageia.org> | 2014-03-01 18:15:17 +0000 |
---|---|---|
committer | Filip Komar <filip@mageia.org> | 2014-03-01 18:15:17 +0000 |
commit | fea2eca9cb50ba0dd1058358bc0feb58304a3d80 (patch) | |
tree | 14473e0a8ed3499e559ff4e957a5ecdbf42dfa3a /en | |
parent | 1f3db960405e08e0f707a5de5810c3c12040709d (diff) | |
download | www-fea2eca9cb50ba0dd1058358bc0feb58304a3d80.tar www-fea2eca9cb50ba0dd1058358bc0feb58304a3d80.tar.gz www-fea2eca9cb50ba0dd1058358bc0feb58304a3d80.tar.bz2 www-fea2eca9cb50ba0dd1058358bc0feb58304a3d80.tar.xz www-fea2eca9cb50ba0dd1058358bc0feb58304a3d80.zip |
first step towards transition from lang files to gettext translation system
Diffstat (limited to 'en')
-rw-r--r-- | en/about/license/license.php | 2 | ||||
-rw-r--r-- | en/about/license/php-mo.php | 154 |
2 files changed, 0 insertions, 156 deletions
diff --git a/en/about/license/license.php b/en/about/license/license.php index a28c8adc2..5745e0826 100644 --- a/en/about/license/license.php +++ b/en/about/license/license.php @@ -17,8 +17,6 @@ function read_license_from_vcs($locale) { array('Warning: Free Software may not necessarily be patent free, and some Free\nSoftware included may be covered by patents in your country. For example, the\nMP3 decoders included may require a license for further usage (see\nhttp://www.mp3licensing.com for more details). If you are unsure if a patent\nmay be applicable to you, check your local laws.'), ); - require_once('php-mo.php'); - if($locale == 'en') { $po_locale = 'libDrakX.pot'; } else { diff --git a/en/about/license/php-mo.php b/en/about/license/php-mo.php deleted file mode 100644 index 470ce80e8..000000000 --- a/en/about/license/php-mo.php +++ /dev/null @@ -1,154 +0,0 @@ -<?php -/** - * based on php.mo 0.1 by Joss Crowcroft (http://www.josscrowcroft.com) - * added case for commented unused string - * fixed "fuzzy flag first line" bug which didn't saved previous proper string at all - * removed unedeed phpmo_convert and phpmo_write_mo_file - * - * Converts gettext translation '.po' files to binary '.mo' files in PHP. - * - * Usage: - * <?php require('php-mo.php'); phpmo_convert( 'input.po', [ 'output.mo' ] ); ?> - * - * NB: - * - If no $output_file specified, output filename is same as $input_file (but .mo) - * - Returns true/false for success/failure - * - No warranty, but if it breaks, please let me know - * - * More info: - * https://github.com/josscrowcroft/php.mo - * - * Based on php-msgfmt by Matthias Bauer (Copyright © 2007), a command-line PHP tool - * for converting .po files to .mo. - * (http://wordpress-soc-2007.googlecode.com/svn/trunk/moeffju/php-msgfmt/msgfmt.php) - * - * License: GPL v3 http://www.opensource.org/licenses/gpl-3.0.html - */ - -function phpmo_clean_helper($x) { - if (is_array($x)) { - foreach ($x as $k => $v) { - $x[$k] = phpmo_clean_helper($v); - } - } else { - if ($x[0] == '"') - $x = substr($x, 1, -1); - $x = str_replace("\"\n\"", '', $x); - $x = str_replace('$', '\\$', $x); - } - return $x; -} - -/* Parse gettext .po files. */ -/* @link http://www.gnu.org/software/gettext/manual/gettext.html#PO-Files */ -function phpmo_parse_po_file($in) { - // read .po file - $fh = @fopen($in, 'r'); - if ($fh === false) { - // Could not open file resource - return false; - } - - // results array - $hash = array (); - // temporary array - $temp = array (); - // state - $state = null; - $fuzzy = false; - - // iterate over lines - while(($line = fgets($fh, 65536)) !== false) { - $line = trim($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] : ''); - - switch ($key) { - case '#,' : // flag... - $fuzzy = in_array('fuzzy', preg_split('/,\s*/', $data)); - case '#' : // translator-comments - case '#.' : // extracted-comments - case '#:' : // reference... - case '#|' : // msgid previous-untranslated-string - break; - case '#~' : // commented-unused-string - $temp = array (); - $state = null; - $fuzzy = false; - break; - case 'msgctxt' : - // context - case 'msgid' : - // untranslated-string - case 'msgid_plural' : - // untranslated-string-plural - $state = $key; - $temp[$state] = $data; - break; - case 'msgstr' : - // translated-string - $state = 'msgstr'; - $temp[$state][] = $data; - break; - default : - if (strpos($key, 'msgstr[') !== FALSE) { - // translated-string-case-n - $state = 'msgstr'; - $temp[$state][] = $data; - } else { - // continued lines - switch ($state) { - case 'msgctxt' : - case 'msgid' : - case 'msgid_plural' : - $temp[$state] .= "\n" . $line; - break; - case 'msgstr' : - $temp[$state][sizeof($temp[$state]) - 1] .= "\n" . $line; - break; - default : - // parse error - fclose($fh); - return FALSE; - } - } - break; - } - } - fclose($fh); - - // add final entry - if ($state == 'msgstr') - $hash[] = $temp; - - // Cleanup data, merge multiline entries, reindex hash for ksort - $temp = $hash; - $hash = array (); - foreach ($temp as $entry) { - foreach ($entry as & $v) { - $v = phpmo_clean_helper($v); - if ($v === FALSE) { - // parse error - return FALSE; - } - } - $hash[$entry['msgid']] = $entry; - } - - return $hash; -} - -?>
\ No newline at end of file |