PHP

PHP knihovna: gettext/gettext

Knihovna pro práci (editace, import a export) s formátem gettext v souborech .po, .mo, .php, .js apod.

Formát gettext je používají pro lokalizaci textů do jednotlivých jazyků i open source řešení jako je WordPress nebo Drupal.

Zdroj

https://github.com/oscarotero/Gettext

Instalace

composer require gettext/gettext

Závislosti

gettext/languages

Třídy

  • GettextTranslation – definice překladu
  • GettextTranslations – kolekce překladů
  • GettextExtractors* – import překladů z různých zdrojů (po, mo, php, js atd.)
  • GettextGenerators* – export překladů to různých formátů (po, mo, php, json atd.)
  • GettextTranslator – použití textů překladu v php šabloně (náhrada za php rozšíření gettext)
  • GettextGettextTranslator – použití php rozšíření gettext

Příklady použití

Import ze souboru .po

$translations = GettextTranslations::fromPoFile('D:/test_import.po');

Vrací:

  • GettextTranslations
    • „term_1“ => GettextTranslation
      • context => „“
      • original => „term_1“
      • translation => „Translation 1“
      • plural protected => „“
      • pluralTranslation => array ()
      • references => array ()
      • comments => array ()
      • extractedComments => array ()
      • flags => array ()
    • „term_2“ => GettextTranslation

Napsat komentář

Vaše e-mailová adresa nebude zveřejněna. Vyžadované informace jsou označeny *