angular-gettext
angular-gettext copied to clipboard
context support for extracting strings from javascript
I know the extractor supports the externalizing the translate-context for the html file. Does it have the corresponding support for the javascript file?
Based on the api, I have gettextCatalog.getString("me", scope, "recipient") in my javascript. I did not see the generated .po file having the entry "msgctxt": "recipient".
Locally, I can make the extractor work for the js file by modifying the walkJs of Extractor.prototype.extractJs method.
if (isGettext(node) || isGetString(node)) {
str = getJSExpression(node.arguments[0]);
context = node.arguments[2] ? getJSExpression(node.arguments[2]) : null;
} else if (isGetPlural(node)) {
singular = getJSExpression(node.arguments[1]);
plural = getJSExpression(node.arguments[2]);
context = node.arguments[4] ? getJSExpression(node.arguments[4]) : null;
}
if (str || singular) {
var leadingComments = node.leadingComments || (parentComment ? parentComment.leadingComments : []);
leadingComments.forEach(function (comment) {
if (comment.value.match(/^\/ .*/)) {
extractedComments.push(comment.value.replace(/^\/ /, ''));
}
});
if (str) {
self.addString(reference, str, plural, comments2String(extractedComments), context);
} else if (singular) {
self.addString(reference, singular, plural, comments2String(extractedComments), context);
}
}
Can the similar fix be added into the next release?
any updates for the same? how to provide context for strings extracted from javascript file?
+1. Is this still unavailable?
Is that merged or not?
@mockingbird-z what is the status of this issue? pending? Because I encounter the same problem here...