Releases: php-gettext/Gettext
3.2
-
From now on Mo generator ignore the empty translations #66 . You can change this behaviour in the static variable:
Gettext\Generators\Mo::$includeEmptyTranslations = true;
-
Changed the plural rules definition for a more reliable source #67
-
Fixed mo generator/extractor #68
-
Gettext\Translations::getPluralsForms()returns a numeric array instead associative.
3.1.1
3.1
- New JsonDictionary generator / extractor #58, 47b66b5
- Improved
Gettext\Utils\Locales::getLocaleInfo(). Now returns language names and territory names #61 - Removed
Gettext\Translation::setOriginal()andGettext\Translation::setContext(). Now these values are no longer mutable. - New method
Gettext\Translation::getClone()to return a clone of a translation with different original/context values. - Improved performance of the
Gettext\Translationson manage translations (insert, find, etc). - New methods
Gettext\Locales::getLanguagesandGettext\Locales::getTerritories - Removed development stuff from downloaded arquives #62
3.0
-
Plural forms are no longer considered when determining translation uniqueness (see #48, #49 ) This removes the plural argument in
Gettext\Translations::find()andGettext\Translations::is(). -
Gettext\Translationsmerges automatically duplicated translations. For example:$translations = new Gettext\Translations(); //Create two equal translations: $t1 = new Gettext\Translation('my-context', '1 comment'); $t2 = new Gettext\Translation('my-context', '1 comment'); //Translate one of them $t1->setTranslation('1 comentario'); //Add a reference to the other $t2->addReference('filename.php', 23); //Add both translations to the translations collection $translations[] = $t1; $translations[] = $t2; //Search for the translation: $found = $translations->find('my-context', '1 comment'); //The translations are merged in one echo $found->getTranslation(); // 1 comentario var_dump($found->getReferences()); // array(array('filename.php', 23))
The merge configuration can be changed in using
Gettext\Translations::$mergeDefaultstatic variable. -
New
Gettext\Translations::MERGE_LANGUAGEconstant to apply the language and plural forms to the merged translations collection. -
New
Gettext\Translations::MERGE_PLURALconstant to merge plural translations into singular translations with the same id (active by default). -
New methods
Gettext\Translations::setPluralForms()andGettext\Translations::getPluralForms()to add the Plural-Forms header and normalize all translations according with the plural count. For example:$translations = new Gettext\Translations(); //Insert a translation with plural: $t = $translations->insert(null, '1 comment', '% comments'); //The plural is not translated yet echo count($t->getPluralTranslation()); //0 //Set the plural form $translations->setPluralForms(2, '(n != 1)'); //Now we have the Plural-Forms header defined echo $translatons->getHeader('Plural-Forms'); // nplurals=2; plural=(n != 1); //And all translations with plurals have the plural translations defined: echo count($t->getPluralTranslation()); //1 //To retrieve the plural forms: $forms = $t->getPluralForms();
-
Gettext\Translations::setLanguage()add automatically the plural forms, using this locale definitions. For example:$translations = new Gettext\Translations(); //Set a locale definition $translations->setLanguage('gl'); //Now we have the plural forms defined echo $translations->getHeader('Plural-Forms'); // nplurals=2; plural=(n != 1);
-
Removed the method
Gettext\Translation::wipeReferences()and added the following methods to delete content:Gettext\Translation\deletePluralTranslation(); Gettext\Translation\deleteReferences(); Gettext\Translation\deleteComments(); Gettext\Translation\deleteExtractedComments(); Gettext\Translation\deleteFlags(); Gettext\Translations\deleteHeader($name); Gettext\Translations\deleteHeaders();
-
The method
Gettext\Translation::setPluralTranslation()does no longer accept null as second argument. -
And many more bugfixes and improvements
2.3.0
2.2.3
2.2.2
2.2.1
2.2.0
- Implemented domains and added new gettext functions:
d__,dp__,dnp__(and the "echo" version:d__e,dp__e,dnp__e) - Changed the way to load the gettext functions to fix #33. Instead being loaded automatically by composer, from now you have the static method
Gettext\Translator::initGettextFunctions($translatorInstance)to load the functions and register the current translator:
//before:
__currentTranslator($translator);
__e('hello world');
//now:
Gettext\Translator::initGettextFunctions($translator);
__e('hello world');