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

Commit

Permalink
Show file tree
Hide file tree
Showing 51 changed files with 845 additions and 240 deletions.
6 changes: 0 additions & 6 deletions src/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,9 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_I18n
*/

namespace Zend\I18n\Exception;

/**
* @category Zend
* @package Zend_I18n
* @subpackage Exception
*/
interface ExceptionInterface
{}
6 changes: 0 additions & 6 deletions src/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,10 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_I18n
*/

namespace Zend\I18n\Exception;

/**
* @category Zend
* @package Zend_I18n
* @subpackage Exception
*/
class InvalidArgumentException extends \InvalidArgumentException implements
ExceptionInterface
{}
6 changes: 0 additions & 6 deletions src/Exception/OutOfBoundsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,10 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_I18n
*/

namespace Zend\I18n\Exception;

/**
* @category Zend
* @package Zend_I18n
* @subpackage Exception
*/
class OutOfBoundsException extends \OutOfBoundsException implements
ExceptionInterface
{}
6 changes: 0 additions & 6 deletions src/Exception/ParseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,9 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_I18n
*/

namespace Zend\I18n\Exception;

/**
* @category Zend
* @package Zend_I18n
* @subpackage Exception
*/
class ParseException extends RuntimeException implements ExceptionInterface
{}
6 changes: 0 additions & 6 deletions src/Exception/RangeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,9 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_I18n
*/

namespace Zend\I18n\Exception;

/**
* @category Zend
* @package Zend_I18n
* @subpackage Exception
*/
class RangeException extends \RangeException implements ExceptionInterface
{}
6 changes: 0 additions & 6 deletions src/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,9 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_I18n
*/

namespace Zend\I18n\Exception;

/**
* @category Zend
* @package Zend_I18n
* @subpackage Exception
*/
class RuntimeException extends \RuntimeException implements ExceptionInterface
{}
6 changes: 0 additions & 6 deletions src/Filter/AbstractLocale.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_I18n
*/

namespace Zend\I18n\Filter;

use Locale;
use Zend\Filter\AbstractFilter;

/**
* @category Zend
* @package Zend_I18n
* @subpackage Filter
*/
abstract class AbstractLocale extends AbstractFilter
{
/**
Expand Down
6 changes: 0 additions & 6 deletions src/Filter/Alnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_I18n
*/

namespace Zend\I18n\Filter;

use Locale;
use Traversable;

/**
* @category Zend
* @package Zend_I18n
* @subpackage Filter
*/
class Alnum extends AbstractLocale
{
/**
Expand Down
6 changes: 0 additions & 6 deletions src/Filter/Alpha.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,12 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_I18n
*/

namespace Zend\I18n\Filter;

use Locale;

/**
* @category Zend
* @package Zend_I18n
* @subpackage Filter
*/
class Alpha extends Alnum
{
/**
Expand Down
6 changes: 0 additions & 6 deletions src/Filter/NumberFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_I18n
*/

namespace Zend\I18n\Filter;
Expand All @@ -15,11 +14,6 @@
use Zend\I18n\Exception;
use Zend\Stdlib\ErrorHandler;

/**
* @category Zend
* @package Zend_I18n
* @subpackage Filter
*/
class NumberFormat extends AbstractLocale
{
protected $options = array(
Expand Down
5 changes: 0 additions & 5 deletions src/Translator/Loader/FileLoaderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_I18n
*/

namespace Zend\I18n\Translator\Loader;

/**
* File loader interface.
*
* @category Zend
* @package Zend_I18n
* @subpackage Translator
*/
interface FileLoaderInterface
{
Expand Down
5 changes: 0 additions & 5 deletions src/Translator/Loader/Gettext.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_I18n
*/

namespace Zend\I18n\Translator\Loader;
Expand All @@ -17,10 +16,6 @@

/**
* Gettext loader.
*
* @category Zend
* @package Zend_I18n
* @subpackage Translator
*/
class Gettext implements FileLoaderInterface
{
Expand Down
81 changes: 81 additions & 0 deletions src/Translator/Loader/Ini.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\I18n\Translator\Loader;

use Zend\Config\Reader\Ini as IniReader;
use Zend\I18n\Exception;
use Zend\I18n\Translator\Plural\Rule as PluralRule;
use Zend\I18n\Translator\TextDomain;

/**
* PHP INI format loader.
*/
class Ini implements FileLoaderInterface
{
/**
* load(): defined by FileLoaderInterface.
*
* @see FileLoaderInterface::load()
* @param string $locale
* @param string $filename
* @return TextDomain|null
* @throws Exception\InvalidArgumentException
*/
public function load($locale, $filename)
{
if (!is_file($filename) || !is_readable($filename)) {
throw new Exception\InvalidArgumentException(sprintf(
'Could not open file %s for reading',
$filename
));
}

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

$list = $messagesNamespaced;
if (isset($messagesNamespaced['translation'])) {
$list = $messagesNamespaced['translation'];
}

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'])) {
$messages[$message['message']] = $message['translation'];
continue;
}
$messages[array_shift($message)] = array_shift($message);
}

if (!is_array($messages)) {
throw new Exception\InvalidArgumentException(sprintf(
'Expected an array, but received %s',
gettype($messages)
));
}

$textDomain = new TextDomain($messages);

if (array_key_exists('plural', $messagesNamespaced)
&& isset($messagesNamespaced['plural']['plural_forms'])
) {
$textDomain->setPluralRule(
PluralRule::fromString($messagesNamespaced['plural']['plural_forms'])
);
}

return $textDomain;
}
}
5 changes: 0 additions & 5 deletions src/Translator/Loader/PhpArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_I18n
*/

namespace Zend\I18n\Translator\Loader;
Expand All @@ -16,10 +15,6 @@

/**
* PHP array loader.
*
* @category Zend
* @package Zend_I18n
* @subpackage Translator
*/
class PhpArray implements FileLoaderInterface
{
Expand Down
5 changes: 0 additions & 5 deletions src/Translator/Loader/RemoteLoaderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_I18n
*/

namespace Zend\I18n\Translator\Loader;

/**
* Remote loader interface.
*
* @category Zend
* @package Zend_I18n
* @subpackage Translator
*/
interface RemoteLoaderInterface
{
Expand Down
8 changes: 2 additions & 6 deletions src/Translator/LoaderPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_I18n
*/

namespace Zend\I18n\Translator;
Expand All @@ -19,10 +18,6 @@
* Enforces that loaders retrieved are either instances of
* Loader\FileLoaderInterface or Loader\RemoteLoaderInterface. Additionally,
* it registers a number of default loaders.
*
* @category Zend
* @package Zend_I18n
* @subpackage Translator
*/
class LoaderPluginManager extends AbstractPluginManager
{
Expand All @@ -32,8 +27,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
5 changes: 0 additions & 5 deletions src/Translator/Plural/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_I18n
*/

namespace Zend\I18n\Translator\Plural;
Expand All @@ -17,10 +16,6 @@
*
* This plural rule parser is implemented after the article "Top Down Operator
* Precedence" described in <http://javascript.crockford.com/tdop/tdop.html>.
*
* @category Zend
* @package Zend_I18n
* @subpackage Translator
*/
class Parser
{
Expand Down
Loading

0 comments on commit 0ff3a48

Please sign in to comment.