6use BadMethodCallException;
 
   14    const MERGE_REMOVE = 2;
 
   15    const MERGE_HEADERS = 4;
 
   16    const MERGE_REFERENCES = 8;
 
   17    const MERGE_COMMENTS = 16;
 
   18    const MERGE_LANGUAGE = 32;
 
   19    const MERGE_PLURAL = 64;
 
   20    const MERGE_OVERRIDE = 128;
 
   22    const HEADER_LANGUAGE = 
'Language';
 
   23    const HEADER_PLURAL = 
'Plural-Forms';
 
   24    const HEADER_DOMAIN = 
'X-Domain';
 
   26    public static $mergeDefault = 93; 
 
   34    public function __construct($input = array(), $flags = 0, $iterator_class = 
'ArrayIterator')
 
   36        $this->headers = array(
 
   37            'Project-Id-Version' => 
'',
 
   38            'Report-Msgid-Bugs-To' => 
'',
 
   39            'Last-Translator' => 
'',
 
   40            'Language-Team' => 
'',
 
   41            'MIME-Version' => 
'1.0',
 
   42            'Content-Type' => 
'text/plain; charset=UTF-8',
 
   43            'Content-Transfer-Encoding' => 
'8bit',
 
   44            'POT-Creation-Date' => 
date(
'c'),
 
   45            'PO-Revision-Date' => 
date(
'c'),
 
   47        $this->headers[self::HEADER_LANGUAGE] = 
'';
 
   48        parent::__construct($input, $flags, $iterator_class);
 
   59        if (!preg_match(
'/^from(\w+)(File|String)$/i', 
$name, $matches)) {
 
   60            throw new BadMethodCallException(
"The method $name does not exists");
 
   63        return call_user_func_array(
'Gettext\\Extractors\\'.$matches[1].
'::from'.$matches[2], $arguments);
 
   75        if (!preg_match(
'/^(addFrom|to)(\w+)(File|String)$/i', 
$name, $matches)) {
 
   76            throw new BadMethodCallException(
"The method $name does not exists");
 
   79        if ($matches[1] === 
'addFrom') {
 
   82            call_user_func_array(
'Gettext\\Extractors\\'.$matches[2].
'::from'.$matches[3], $arguments);
 
   87        array_unshift($arguments, $this);
 
   89        return call_user_func_array(
'Gettext\\Generators\\'.$matches[2].
'::to'.$matches[3], $arguments);
 
   99        foreach ($this as 
$key => $translation) {
 
  100            $array[
$key] = clone $translation;
 
  103        $this->exchangeArray($array);
 
  119            throw new \InvalidArgumentException(
'Only instances of Gettext\\Translation must be added to a Gettext\\Translations');
 
  122        $id = $value->getId();
 
  124        if ($this->offsetExists(
$id)) {
 
  125            $this[
$id]->mergeWith($value);
 
  126            $this[
$id]->setTranslationCount($this->translationCount);
 
  131        $value->setTranslationCount($this->translationCount);
 
  133        parent::offsetSet(
$id, $value);
 
  146        $this->setHeader(self::HEADER_PLURAL, 
"nplurals={$count}; plural={$rule};");
 
  158        if (!empty(
$header) && preg_match(
'/^nplurals\s*=\s*(\d+)\s*;\s*plural\s*=\s*([^;]+)\s*;$/', 
$header, $matches)) {
 
  159            return array(intval($matches[1]), $matches[2]);
 
  172        $this->headers[
$name] = trim($value);
 
  174        if (
$name === self::HEADER_PLURAL) {
 
  175            if ($forms = $this->getPluralForms()) {
 
  176                $this->translationCount = $forms[0];
 
  178                foreach ($this as 
$t) {
 
  179                    $t->setTranslationCount($this->translationCount);
 
  182                $this->translationCount = 
null;
 
  196        return isset($this->headers[
$name]) ? $this->headers[
$name] : 
null;
 
  206        return $this->headers;
 
  214        $this->headers = array();
 
  224        unset($this->headers[
$name]);
 
  234        return $this->
getHeader(self::HEADER_LANGUAGE);
 
  246        $this->setHeader(self::HEADER_LANGUAGE, trim($language));
 
  248        if ((
$info = Language::getById($language))) {
 
  249            $this->setPluralForms(count(
$info->categories), 
$info->formula);
 
  264        $language = $this->getLanguage();
 
  266        return (is_string($language) && ($language !== 
'')) ? true : 
false;
 
  276        $this->setHeader(self::HEADER_DOMAIN, trim(
$domain));
 
  286        return $this->
getHeader(self::HEADER_DOMAIN);
 
  309    public function find($context, $original = 
'')
 
  312            $id = $context->getId();
 
  314            $id = Translation::generateId($context, $original);
 
  317        return $this->offsetExists(
$id) ? $this[
$id] : 
false;
 
  329    public function insert($context, $original, $plural = 
'')
 
  331        return $this->offsetSet(
null, 
new Translation($context, $original, $plural));
 
  342        if ($method === 
null) {
 
  343            $method = self::$mergeDefault;
 
  346        if ($method & self::MERGE_HEADERS) {
 
  349                    $this->setHeader(
$name, $value);
 
  354        $add = (boolean) ($method & self::MERGE_ADD);
 
  356        foreach ($translations as $entry) {
 
  357            if (($existing = $this->find($entry))) {
 
  358                $existing->mergeWith($entry, $method);
 
  360                $this[] = clone $entry;
 
  364        if ($method & self::MERGE_REMOVE) {
 
  367            foreach ($this as $entry) {
 
  368                if ($translations->
find($entry)) {
 
  369                    $filtered[] = $entry;
 
  373            $this->exchangeArray($filtered);
 
  376        if ($method & self::MERGE_LANGUAGE) {
 
  381                if (!empty($language)) {
 
  382                    $this->setLanguage($language);
 
  385                if (!empty($language)) {
 
  386                    $this->setHeader(self::HEADER_LANGUAGE, $language);
 
  389                $this->setPluralForms($pluralForm[0], $pluralForm[1]);
 
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
if(!array_key_exists('domain', $_REQUEST)) $domain
An exception for terminatinating execution or to throw for unit testing.
Main class to convert the plural rules of a language from CLDR to gettext.
Class to manage a translation string.
Class to manage a collection of translations.
getHeaders()
Returns all header for this translations.
deleteHeaders()
Removes all headers.
hasDomain()
Checks whether the domain is empty or not.
getHeader($name)
Returns a header value.
setHeader($name, $value)
Set a new header.
getLanguage()
Returns the language value.
offsetSet($index, $value)
Control the new translations added.
mergeWith(Translations $translations, $method=null)
Merges this translations with other translations.
getPluralForms()
Returns the parsed plural definition.
setPluralForms($count, $rule)
Set the plural definition.
__clone()
Magic method to clone each translation on clone the translations object.
deleteHeader($name)
Removes one header.
hasLanguage()
Checks whether the language is empty or not.
find($context, $original='')
Search for a specific translation.
getDomain()
Returns the domain.
insert($context, $original, $plural='')
Creates and insert/merges a new translation.
setLanguage($language)
Sets the language and the plural forms.
__construct($input=array(), $flags=0, $iterator_class='ArrayIterator')
__call($name, $arguments)
Magic method to import/export the translations to a specific format For example: $translations->toMoF...
static __callStatic($name, $arguments)
Magic method to create new instances using extractors For example: Translations::fromMoFile($filename...
setDomain($domain)
Set a new domain for this translations.
if(!array_key_exists('StateId', $_REQUEST)) $id