ESM support
@AlexMost Been using ttag recently, was disappointed gettext couldn't support my Javascript/Typescript codebase.
Just experimenting with the babel plugins, not written any babel plugins before so your feedback would be very helpful 🙏
Changes to /src
My thinking is that if we've got a ImportDeclaration which passes the if (!isTtagImport(node)) return; then we cna be pretty sure there is an intent from the developer to be using ttag for localization.
Rather than throwing You should use ttag imports in form: "import { t } from \'ttag\'" we can import the default alias names so that we can catch t, gettext, ngettext,...
Tests added
[Will update..]
Have been looking at this for a little bit 😅
Wondering if it might be easier and more customizable for developers if the plugin decoupled the links between the ExpressionStatement names such as t, gettext, ....
At the moment context.addAlias and context.addImport are used to kind of register the nodes into the context.
Could let developers define the ExpressionStatements in come kind of config .ttagrc which might look like
{
'tag-gettext': ['t', 'myCustomMethod'],
'jsxtag-gettext': ['jt'],
gettext: ['gettext'],
ngettext: ['ngettext'],
msgid: ['msgid'],
context: ['c'],
}
Would be quite a big refactor though (almost new plugin), wondering if there has been any thoughts/development in the direction already?