X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=class%2Fl10n%2Fgettext.class.php;h=d8a9b78ae4a2fdf307c56582cf13d7c8abeb5e03;hp=cc1278c706748ccf2f9bf558c89acabec7404ef1;hb=768c6816fba75ca42198049e0de77522912f8d00;hpb=0309ed16463f4536c88a4bc801959150f9257545 diff --git a/class/l10n/gettext.class.php b/class/l10n/gettext.class.php index cc1278c7..d8a9b78a 100644 --- a/class/l10n/gettext.class.php +++ b/class/l10n/gettext.class.php @@ -1,27 +1,31 @@ . * * This file is part of PHP-gettext. * - * PHP-gettext is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * PHP-gettext is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * PHP-gettext is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * PHP-gettext is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with PHP-gettext; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the GNU General Public License + * along with PHP-gettext; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * + * @copyright 2004-2011 The SquirrelMail Project Team + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * @version $Id$ * @package squirrelmail * @subpackage i18n */ - + /** * Class that uses parsed translation input objects * @package squirrelmail @@ -57,9 +61,9 @@ class gettext_reader { $byte[$i]=ord($this->STREAM->read(1)); } //print sprintf("pos: %d\n",$this->STREAM->currentpos()); - if ($this->BYTEORDER == 0) + if ($this->BYTEORDER == 0) return (int)(($byte[0]) | ($byte[1]<<8) | ($byte[2]<<16) | ($byte[3]<<24)); - else + else return (int)(($byte[3]) | ($byte[2]<<8) | ($byte[1]<<16) | ($byte[0]<<24)); } @@ -161,7 +165,7 @@ class gettext_reader { $data = $this->STREAM->read($length); return (string)$data; } - + /** * binary search for string * @param string $string @@ -190,7 +194,7 @@ class gettext_reader { if ($cmp == 0) { $this->_HASHED[$string] = $half; return $half; - } elseif ($cmp<0) + } elseif ($cmp<0) return $this->find_string($string,$start,$half); else return $this->find_string($string,$half,$end); @@ -203,11 +207,11 @@ class gettext_reader { * @return string translated string */ function translate($string) { - if ($this->error > 0) return $string; + if ($this->error > 0) return $string; $num = $this->find_string($string, 0, $this->total); if ($num == -1) return $string; - else + else return $this->get_translation_number($num); } @@ -220,12 +224,12 @@ class gettext_reader { // this is true, right? // cache header field for plural forms - if (isset($this->pluralheader) && is_string($this->pluralheader)) + if (isset($this->pluralheader) && is_string($this->pluralheader)) return $this->pluralheader; else { $header = $this->get_translation_number(0); - if (eregi("plural-forms: (.*)\n",$header,$regs)) { + if (preg_match('/plural-forms: (.*)\n/i',$header,$regs)) { $expr = $regs[1]; } else { $expr = "nplurals=2; plural=n == 1 ? 0 : 1;"; @@ -266,7 +270,7 @@ class gettext_reader { $result=-1; } else { // find out the appropriate form - $select = $this->select_string($number); + $select = $this->select_string($number); // this should contains all strings separated by NULLs $result = $this->find_string($single.chr(0).$plural,0,$this->total); @@ -284,4 +288,3 @@ class gettext_reader { } } } -?> \ No newline at end of file