I am using ngx-translate to support I18N in my angular 5 application.
I wanted to know how i can specify the context for the word /sentence getting translated?
Example code from HTML:
<span class="arc-gauge-title">{{title | translate}}</span>
<app-change-pages-dropdown [pageTitle]="pageTitle | translate"></app-change-pages-dropdown>
Example code from TS file:
fTitle = TRANSLATE("Completion rate");
"TRANSLATE" is a service which extracts the text from translation. Below is the code:
export function TRANSLATE(str: string) {
return str;
}
I am using "ngx-translate-extract" to extract strings for translation. Below is the command from package.json:
"extract-translations": "ngx-translate-extract --input ./src --output ./src/assets/i18n/ --clean --sort --format namespaced-json --marker TRANSLATE"
Any help in specifying the context for the string to be translated is appreciated.
Thanks in advance.
ngx-translate
supports files that would contain this 'context'. They only support key/value pairs where the key is astring
and the value is either astring
or an object of the key/value pairs. Looking at the unit test code for thengx-translate-extract
library, I don't see any examples that would consist of this type of 'context' specification so I don't think they support that: github.com/biesbjerg/ngx-translate-extract/blob/master/tests/… – Daniel W Strimpel