angular-gettext icon indicating copy to clipboard operation
angular-gettext copied to clipboard

gettextCatalog.getString() not extracted when using alias

Open yeou opened this issue 10 years ago • 6 comments

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?

yeou avatar Oct 23 '15 10:10 yeou

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)) {

yeou avatar Oct 23 '15 11:10 yeou

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.

rubenv avatar Oct 23 '15 13:10 rubenv

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?

yeou avatar Oct 23 '15 13:10 yeou

Or is it not compatible with ES6?

yeou avatar Oct 26 '15 13:10 yeou

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:

deini avatar Mar 25 '16 18:03 deini

Never mind, found it here https://github.com/rubenv/angular-gettext-tools/pull/29/files

deini avatar Mar 25 '16 19:03 deini