vegas-cmf / core

Vegas CMF Core
MIT License
30 stars 7 forks source link

i18n #56

Closed krzysztof-kabala closed 8 years ago

krzysztof-kabala commented 8 years ago

php cli/cli.php vegas:i18n generate

Task will generate "{langDir}/{lang}/LC_MESSAGES/messages.po" file for each $langs language item. If final file exists, overwrite it by adding new translations, but without modify translated items.

Task requires xgettext installed, node.js and xgettext-template (as global), see:

Supported file types:

HOWTO: 1) Extend I18nTask into Your app 2) Overwrite $directories, $langDir and $langs (+ other params if needed) 3) Overwrite addToFinalPo(PO_FILE_PATH); to add database translation into final.PO You may use generatePoContent method to generate PO content from array of string or array [msgid,?msgstr,?comment] where "?" keys are optional (see sample below) 4) Use "POEdit" to manage translations

Sample of addToFinalPo using:

protected function addToFinalPo($tmpPo)
{
$newPo = $this->getTmpFile();

file_put_contents($newPo, $this->generatePoContent([
'message1', 'other message', 'dynamic %s message'
]));

$this->addPo($tmpPo, $newPo);
}

If You are using non-utf8 standard charset, consider adding own header into PO files.

arius86 commented 8 years ago

Nice job! IMO we can create additional package for that instead putting this into core :)