]> git.wh0rd.org - tt-rss.git/commitdiff
lib: Upgrade php-gettext from 1.0.11 to 1.0.12
authorAnders Kaseorg <andersk@mit.edu>
Fri, 20 Jan 2017 19:49:24 +0000 (14:49 -0500)
committerAnders Kaseorg <andersk@mit.edu>
Sat, 21 Jan 2017 20:01:14 +0000 (15:01 -0500)
https://launchpad.net/php-gettext

The local change to rename the gettext_reader function to
__construct (commit 00b6b66827c5ce0c103399f2742581fa90d50a97) has been
preserved.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
lib/gettext/gettext.inc
lib/gettext/gettext.php

index 00b966692cc7d16e1acc19ed21bd0e1fd3afa46c..c9f7dc01681a26f2a53d9219edfaf3d6eb807b0a 100644 (file)
@@ -174,14 +174,13 @@ function _get_codeset($domain=null) {
  * Convert the given string to the encoding set by bind_textdomain_codeset.
  */
 function _encode($text) {
+  $target_encoding = _get_codeset();
+  if (function_exists("mb_detect_encoding")) {
     $source_encoding = mb_detect_encoding($text);
-    $target_encoding = _get_codeset();
-    if ($source_encoding != $target_encoding) {
-        return mb_convert_encoding($text, $target_encoding, $source_encoding);
-    }
-    else {
-        return $text;
-    }
+    if ($source_encoding != $target_encoding)
+      $text = mb_convert_encoding($text, $target_encoding, $source_encoding);
+  }
+  return $text;
 }
 
 
index 81af55509992f130d383a8da2287a8bdbfafa92d..edbd933047efe79da8a9b234eb433bb2418f8505 100755 (executable)
@@ -350,6 +350,10 @@ class gettext_reader {
    * @return int array index of the right plural form
    */
   function select_string($n) {
+    if (!is_int($n)) {
+      throw new InvalidArgumentException(
+        "Select_string only accepts integers: " . $n);
+    }
     $string = $this->get_plural_forms();
     $string = str_replace('nplurals',"\$total",$string);
     $string = str_replace("n",$n,$string);