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

Commit

Permalink
Browse files Browse the repository at this point in the history
- whitespace around conditionals
- remove commented code
- EOF markers
  • Loading branch information
weierophinney committed Dec 10, 2012
1 parent fd6e1e5 commit fd6f1d5
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 23 deletions.
18 changes: 10 additions & 8 deletions src/Translator/Loader/Ini.php
Expand Up @@ -42,21 +42,22 @@ public function load($locale, $filename)
));
}

$messages = array();
$iniReader = new IniReader();
$messages = array();
$iniReader = new IniReader();
$messagesNamespaced = $iniReader->fromFile($filename);

$list = $messagesNamespaced;
if(isset($messagesNamespaced['translation'])) {
if (isset($messagesNamespaced['translation'])) {
$list = $messagesNamespaced['translation'];
}
foreach($list as $message) {
if(!is_array($message) || count($message) < 2) {

foreach ($list as $message) {
if (!is_array($message) || count($message) < 2) {
throw new Exception\InvalidArgumentException(
'Each INI row must be an array with message and translation'
);
}
if(isset($message['message']) && isset($message['translation'])) {
if (isset($message['message']) && isset($message['translation'])) {
$messages[$message['message']] = $message['translation'];
continue;
}
Expand All @@ -72,8 +73,9 @@ public function load($locale, $filename)

$textDomain = new TextDomain($messages);

if (array_key_exists('plural', $messagesNamespaced) &&
isset($messagesNamespaced['plural']['plural_forms'])) {
if (array_key_exists('plural', $messagesNamespaced)
&& isset($messagesNamespaced['plural']['plural_forms'])
) {
$textDomain->setPluralRule(
PluralRule::fromString($messagesNamespaced['plural']['plural_forms'])
);
Expand Down
2 changes: 1 addition & 1 deletion src/Translator/LoaderPluginManager.php
Expand Up @@ -32,9 +32,9 @@ class LoaderPluginManager extends AbstractPluginManager
* @var array
*/
protected $invokableClasses = array(
'phparray' => 'Zend\I18n\Translator\Loader\PhpArray',
'gettext' => 'Zend\I18n\Translator\Loader\Gettext',
'ini' => 'Zend\I18n\Translator\Loader\Ini',
'phparray' => 'Zend\I18n\Translator\Loader\PhpArray',
);

/**
Expand Down
9 changes: 0 additions & 9 deletions test/Translator/Loader/IniTest.php
Expand Up @@ -21,17 +21,9 @@ class IniTest extends TestCase

public function setUp()
{
//$this->originalLocale = Locale::getDefault();
//Locale::setDefault('en_EN');

$this->testFilesDir = realpath(__DIR__ . '/../_files');
}

public function tearDown()
{
//Locale::setDefault($this->originalLocale);
}

public function testLoaderFailsToLoadMissingFile()
{
$loader = new IniLoader();
Expand Down Expand Up @@ -62,7 +54,6 @@ public function testLoaderFailsToLoadBadSyntax()
$loader->load('en_EN', $this->testFilesDir . '/failed_syntax.ini');
}


public function testLoaderReturnsValidTextDomain()
{
$loader = new IniLoader();
Expand Down
2 changes: 1 addition & 1 deletion test/Translator/_files/failed.ini
@@ -1 +1 @@
identifier1 = "Message 1"
identifier1 = "Message 1"
2 changes: 1 addition & 1 deletion test/Translator/_files/failed_syntax.ini
@@ -1 +1 @@
identifier1[] = "Message 1"
identifier1[] = "Message 1"
2 changes: 1 addition & 1 deletion test/Translator/_files/translation_en.ini
Expand Up @@ -23,4 +23,4 @@ identifier6.message = "Cooking furniture"
identifier6.translation = "Küchen Möbel (en)"

identifier7.message = "Küchen Möbel"
identifier7.translation = "Cooking furniture (en)"
identifier7.translation = "Cooking furniture (en)"
2 changes: 1 addition & 1 deletion test/Translator/_files/translation_en_simple_syntax.ini
Expand Up @@ -23,4 +23,4 @@ identifier6[] = "Cooking furniture"
identifier6[] = "Küchen Möbel (en)"

identifier7[] = "Küchen Möbel"
identifier7[] = "Cooking furniture (en)"
identifier7[] = "Cooking furniture (en)"
2 changes: 1 addition & 1 deletion test/Translator/_files/translation_en_without_plural.ini
Expand Up @@ -19,4 +19,4 @@ identifier6.message = "Cooking furniture"
identifier6.translation = "Küchen Möbel (en)"

identifier7.message = "Küchen Möbel"
identifier7.translation = "Cooking furniture (en)"
identifier7.translation = "Cooking furniture (en)"

0 comments on commit fd6f1d5

Please sign in to comment.