diff options
author | Filip Komar <filip@mageia.org> | 2013-07-14 18:34:25 +0000 |
---|---|---|
committer | Filip Komar <filip@mageia.org> | 2013-07-14 18:34:25 +0000 |
commit | 42d540a56e4459a9157e7fb8f95160182d5e2e6f (patch) | |
tree | f2a7e8369dac02014cddef19394da97d113fad5e /en/about/license/php-mo.php | |
parent | afafa9510bfa64b1b055315e4ebbbb44a039b605 (diff) | |
download | www-42d540a56e4459a9157e7fb8f95160182d5e2e6f.tar www-42d540a56e4459a9157e7fb8f95160182d5e2e6f.tar.gz www-42d540a56e4459a9157e7fb8f95160182d5e2e6f.tar.bz2 www-42d540a56e4459a9157e7fb8f95160182d5e2e6f.tar.xz www-42d540a56e4459a9157e7fb8f95160182d5e2e6f.zip |
license page refactored, updated, included in i18n report and linked in map. map.en.lang sync. small addition on community page
Diffstat (limited to 'en/about/license/php-mo.php')
-rw-r--r-- | en/about/license/php-mo.php | 87 |
1 files changed, 4 insertions, 83 deletions
diff --git a/en/about/license/php-mo.php b/en/about/license/php-mo.php index 6e2159a25..470ce80e8 100644 --- a/en/about/license/php-mo.php +++ b/en/about/license/php-mo.php @@ -1,6 +1,9 @@ <?php /** - * php.mo 0.1 by Joss Crowcroft (http://www.josscrowcroft.com) + * 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. * @@ -22,22 +25,6 @@ * License: GPL v3 http://www.opensource.org/licenses/gpl-3.0.html */ -/** - * The main .po to .mo function - */ -function phpmo_convert($input, $output = false) { - if ( !$output ) - $output = str_replace( '.po', '.mo', $input ); - - $hash = phpmo_parse_po_file( $input ); - if ( $hash === false ) { - return false; - } else { - phpmo_write_mo_file( $hash, $output ); - return true; - } -} - function phpmo_clean_helper($x) { if (is_array($x)) { foreach ($x as $k => $v) { @@ -164,70 +151,4 @@ function phpmo_parse_po_file($in) { return $hash; } -/* Write a GNU gettext style machine object. */ -/* @link http://www.gnu.org/software/gettext/manual/gettext.html#MO-Files */ -function phpmo_write_mo_file($hash, $out) { - // sort by msgid - ksort($hash, SORT_STRING); - // our mo file data - $mo = ''; - // header data - $offsets = array (); - $ids = ''; - $strings = ''; - - foreach ($hash as $entry) { - $id = $entry['msgid']; - if (isset ($entry['msgid_plural'])) - $id .= "\x00" . $entry['msgid_plural']; - // context is merged into id, separated by EOT (\x04) - if (array_key_exists('msgctxt', $entry)) - $id = $entry['msgctxt'] . "\x04" . $id; - // plural msgstrs are NUL-separated - $str = implode("\x00", $entry['msgstr']); - // keep track of offsets - $offsets[] = array ( - strlen($ids - ), strlen($id), strlen($strings), strlen($str)); - // plural msgids are not stored (?) - $ids .= $id . "\x00"; - $strings .= $str . "\x00"; - } - - // keys start after the header (7 words) + index tables ($#hash * 4 words) - $key_start = 7 * 4 + sizeof($hash) * 4 * 4; - // values start right after the keys - $value_start = $key_start +strlen($ids); - // first all key offsets, then all value offsets - $key_offsets = array (); - $value_offsets = array (); - // calculate - foreach ($offsets as $v) { - list ($o1, $l1, $o2, $l2) = $v; - $key_offsets[] = $l1; - $key_offsets[] = $o1 + $key_start; - $value_offsets[] = $l2; - $value_offsets[] = $o2 + $value_start; - } - $offsets = array_merge($key_offsets, $value_offsets); - - // write header - $mo .= pack('Iiiiiii', 0x950412de, // magic number - 0, // version - sizeof($hash), // number of entries in the catalog - 7 * 4, // key index offset - 7 * 4 + sizeof($hash) * 8, // value index offset, - 0, // hashtable size (unused, thus 0) - $key_start // hashtable offset - ); - // offsets - foreach ($offsets as $offset) - $mo .= pack('i', $offset); - // ids - $mo .= $ids; - // strings - $mo .= $strings; - - file_put_contents($out, $mo); -} ?>
\ No newline at end of file |