Open rubenv opened 10 years ago
Until this lands in documentation can you please add simple examples here?
I will start with the translate
directive which is:
<span translate translate-context="MY_CONTEXT">MY_STRING</span>
How do we use it with gettextCatalog.getString
?
How do we use it with gettextCatalog.getString?
You can use gettextCatalog.getString("My string", null, "context")
(the second parameter is an interpolation scope).
Be aware though: I'm not entirely sure those context strings in JS are being extracted already.
Tried right before my previous post that way but it was not extracted. Any ETA on that part?
Until it's ready, should I just create a dummy pseudo template with translate
directives for the extractor and use the strings later with the getString
in js? Is there any more elegant way of doing that?
PS. the code that uses the gettextCatalog
directly for translations is outside angular and I don't want to hack manual html compilation just for those translations.
And what about usage of context in attributes?
<input type="text" placeholder="{{'My string' | translate)}}" />
The translate filter uses gettextCatalog.getString() so it should be able to fetch translation by adding context as a parameter to the translate filter:
<input type="text" placeholder="{{'My string' | translate:'Context for my string'}}" />
But the angular-gettext-tools doesn't seem to be able to extract strings that use translate filter with the context attribute added yet. :/
anyone succees with angular-gettext-tools to extract any context type at all? I've made changes but nothing new extracted.
<span translate-context="Account" translate>Enabled</span>
var foo = gettextCatalog.getString('Failed', null, 'Feed');
Is that not ready yet? (btw +1 to have changelog)
At least the first (html attribute) should work with recent versions of gettext. What version do you use and can you try it with latest (2.1.0)?
@larvanitis @rubenv well I've tried this and nothing got extracted. moreover translation stopped working for phrases annoted using context markers. (yes I'm using latest extrctor and gettext).
Fixed in #16 by the great @simon04
In my opinion the extraction of a string from Javascript file giving context does not work as expected. I have one word in two angular modules that should be translated differently. Here's what I did:
msgctxt
appears in both .po
filestranslations.js
file that contains the translations of all modules.
Result: Only one gets translated properly. The other one is not translated at all.Any clues on this?
See https://github.com/rubenv/angular-gettext/issues/53.
Should probably be a page in the advanced section.
A good example is needed here. Someone suggested
invoice
, which might be a verb or a noun depending on the context.