angular-gettext
angular-gettext copied to clipboard
gettextCatalog.getString() not extracted when using alias
I'm using angular-gettext in a ES6 project and i wrapped the function like this:
this._t = (...args) => {
return gettextCatalog.getString(...args);
};
this._t('Translate me...')
But when I use this none of my translations get extracted. Is there an option to configure this?
Basically for this to work I need something like this in node_modules/angular-gettext-tools/lib/extract.js:
function isGettextAlias(node) {
return node !== null && node.type === 'CallExpression' &&
node.callee.type === 'MemberExpression' &&
node.callee.object !== null &&
node.callee.property.name === '_t';
}
and this
if (isGettext(node) || isGetString(node) || isGettextAlias(node)) {
return gettextCatalog.getString(...args);
Note that always calling gettextCatalog.getString is not what you want to be doing.
Is there an option to configure this?
There's an option markerName which allows you to alias gettext(), which is what you want to be using.
Setting a markerName to _t does not work with the function above. I think it's because I use this._t()
Is there a way to fix this?
Or is it not compatible with ES6?
I also have this question, I can't seem to get this working outside of my constructors.
Calling gettext() directly in the constructors work, however trying to call it from a class function doesn't work this._gettext().
Any suggestions? :dancer:
Never mind, found it here https://github.com/rubenv/angular-gettext-tools/pull/29/files