Skip to content

Releases: php-gettext/Gettext

3.2

12 Feb 13:16

Choose a tag to compare

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

03 Feb 14:55

Choose a tag to compare

Fixed Po extractor without headers #65

3.1

28 Jan 15:30

Choose a tag to compare

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() and Gettext\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\Translations on manage translations (insert, find, etc).
  • New methods Gettext\Locales::getLanguages and Gettext\Locales::getTerritories
  • Removed development stuff from downloaded arquives #62

3.0

22 Jan 22:12

Choose a tag to compare

3.0
  • Plural forms are no longer considered when determining translation uniqueness (see #48, #49 ) This removes the plural argument in Gettext\Translations::find() and Gettext\Translations::is().

  • Gettext\Translations merges 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::$mergeDefault static variable.

  • New Gettext\Translations::MERGE_LANGUAGE constant to apply the language and plural forms to the merged translations collection.

  • New Gettext\Translations::MERGE_PLURAL constant to merge plural translations into singular translations with the same id (active by default).

  • New methods Gettext\Translations::setPluralForms() and Gettext\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

19 Jan 18:08

Choose a tag to compare

  • Fixed references parser in .po files #39
  • Fixed po parser with indented values #40
  • Extracted comments and flag comments are stored in a diferent place. More info #38
  • Fixed warning on reading an empty file #43
  • New po generator/extractor (thanks @mlocati)
  • Added PHP 5.6 and HHMV compatibility

2.2.3

07 Jan 19:26

Choose a tag to compare

Fixed Translations::mergeWith() method #36

2.2.2

07 Jan 10:27

Choose a tag to compare

Removed a exception throwed when no translations are loaded by the translator and added a fallback #35

2.2.1

06 Jan 18:11

Choose a tag to compare

Fixed bug in php5.3 #34

2.2.0

17 Dec 23:17

Choose a tag to compare

  • 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');

2.1.1

17 Dec 19:54

Choose a tag to compare

  • Line number in the references is optional #32
  • Added the default header "language" in .po files (162ee49)
  • Added more tests, improved documentation