vegas-cmf / core

Vegas CMF Core
MIT License
30 stars 7 forks source link

i18n task #55

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.

coveralls commented 8 years ago

Coverage Status

Coverage decreased (-8.0%) to 83.879% when pulling 90b0c728da20b03ea749914b0d709cf44a3316ab on krzysztof-kabala:v1.1 into 7430ea6c785cde5bf92374652ab25664a5ad34fc on vegas-cmf:v1.1.