From 00fc0f45cbd73391212a887b64e3a30e57662d7e Mon Sep 17 00:00:00 2001 From: Denis Portnov Date: Fri, 29 Jun 2012 23:32:31 +0400 Subject: [PATCH] better factory configuration --- src/Translator/Loader/Gettext.php | 10 +++------- src/Translator/Translator.php | 9 +++++---- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/Translator/Loader/Gettext.php b/src/Translator/Loader/Gettext.php index 6320c10a..2b47e414 100644 --- a/src/Translator/Loader/Gettext.php +++ b/src/Translator/Loader/Gettext.php @@ -74,15 +74,11 @@ public function load($filename, $locale) // Verify magic number $magic = fread($this->file, 4); - // 32-bit machine is little-endian - if (PHP_INT_SIZE < 8) { - $magic = strrev($magic); - } - if ($magic === "\x95\x04\x12\xde") { - $this->littleEndian = true; - } elseif ($magic === "\xde\x12\x04\x95") { + if ($magic == "\x95\x04\x12\xde") { $this->littleEndian = false; + } elseif ($magic == "\xde\x12\x04\x95") { + $this->littleEndian = true; } else { fclose($this->file); throw new Exception\InvalidArgumentException(sprintf( diff --git a/src/Translator/Translator.php b/src/Translator/Translator.php index 89e50e4b..5e1452e4 100644 --- a/src/Translator/Translator.php +++ b/src/Translator/Translator.php @@ -111,10 +111,11 @@ public static function factory($options) // locales if (isset($options['locale'])) { - $translator->setLocale($options['locale']); - } - if (isset($options['fallback_locale'])) { - $translator->setFallbackLocale($options['fallback_locale']); + $locales = (array) $options['locale']; + $translator->setLocale(array_shift($locales)); + if (count($locales) > 0) { + $translator->setFallbackLocale(array_shift($locales)); + } } // patterns