Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Extraction of context information for I18n #75

Closed
deceze opened this issue Dec 21, 2012 · 4 comments
Closed

Extraction of context information for I18n #75

deceze opened this issue Dec 21, 2012 · 4 comments

Comments

@deceze
Copy link

deceze commented Dec 21, 2012

The way the gettext function is supported using the trans tag is too limited. Specifically:

  1. Compiling the templates and running xgettext against them adds meaningless file names and line numbers to the extracted strings, which do not help at all.

  2. There's no way to add translator comments to the extracted strings, like:

    // Translators: This is "Update" as a noun, not as a verb.
    echo gettext("Update");
    

    xgettext is able to extract those, but there's no way to embed such comments when compiling a Twig template.

For complex projects with distributed translators, both these features are rather important. I'm afraid a native extractor that can parse Twig templates is necessary for this.

@deceze
Copy link
Author

deceze commented Dec 22, 2012

In the meantime I implemented a complete native string extractor which uses the Twig lexer and parser. I also took the opportunity to extend the gettext support to use the system more fully (domains, categories, contexts, plurals, string formatting).

The only thing missing is a decent library for writing the extracted strings to a PO file. Does anyone happen to know one? Otherwise I'll have to write one too.

Once that's done and it's brushed up a bit I'll attach the code here...

@deceze
Copy link
Author

deceze commented Dec 23, 2012

I did not, but this is still rather limited for my needs. A single trans tag is very limited for complex use. I have added all possible gettext() variations in my extension (_d, _n, _p, _dcn etc. etc.), not to mention extractable comments.

@deceze
Copy link
Author

deceze commented Dec 24, 2012

Issue superseded by #76.

@deceze deceze closed this as completed Dec 24, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants