Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
better factory configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
denixport committed Jun 29, 2012
1 parent 7ebbd12 commit 00fc0f4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
10 changes: 3 additions & 7 deletions src/Translator/Loader/Gettext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
9 changes: 5 additions & 4 deletions src/Translator/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 00fc0f4

Please sign in to comment.