Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
New "translate-attr" directive describing which attribute(s) value(s) must be translated #226
I encountered a problem translating attribute values like
But this adds unnecessary obfuscation of the html attribute itself. My proposal is to create new directive say
It could greatly simplify elements which have more than one attribute for translation like this:
It looks easier to read by a human, it removes "logic" from attribute values so non-programmer could easily find the text that will be translated reducing the number of possible errors, looks more "HTML-ish". And also I suppose it is easier for parser to extract text compared to filter approach.
I found the following "custom annotations" ability of angular-gettext at https://angular-gettext.rocketeer.be/dev-guide/custom-annotations/ which could be used in this situation. But I also found that it only works for elements without content (so the sample with placeholder attribute of an input element is not good enough). If you for example try to do the same for title attribute of an label element that have some text content, grunt-angular-gettext will extract the label text, not the title attribute value. So if you have:
Extraction will extract only "Label text content".
So I have modified the
I have changed the following block in
After that the usage in Gruntfile.js (for attributes
It is obvious that including these specific attributes both in
Note: I didn't started any tests after the change of extract.js
I must confirm issue posted by @varadero.
If you have
nggettext_extract output is:
The only way here is to use translate filter like: