Skip to content
This repository has been archived by the owner on Aug 10, 2022. It is now read-only.

i18n task #55

Closed
wants to merge 9 commits into from
Closed

i18n task #55

wants to merge 9 commits into from

Conversation

krzysztof-kabala
Copy link

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:

  • PHP
  • VOLT

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
Copy link

Coverage Status

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants