summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/gettext/gettext.inc13
-rwxr-xr-xlib/gettext/gettext.php4
2 files changed, 10 insertions, 7 deletions
diff --git a/lib/gettext/gettext.inc b/lib/gettext/gettext.inc
index 00b966692..c9f7dc016 100644
--- a/lib/gettext/gettext.inc
+++ b/lib/gettext/gettext.inc
@@ -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;
}
diff --git a/lib/gettext/gettext.php b/lib/gettext/gettext.php
index 81af55509..edbd93304 100755
--- a/lib/gettext/gettext.php
+++ b/lib/gettext/gettext.php
@@ -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);