Closed
Description
Finalize plugin for extracting messages from typescript files. This need somebody with Typescript experience.
Status
Base of plugin is created in typescript-extract-messages package (original version created by @johansigfrids). It uses the same test suite as babel-plugin-extract-messages
. Extracting of messages works, but there're few problems:
- babel plugin also transforms file and removes
i18nMark
functions, because they are used only to mark strings for extraction. Typescript plugin so far doesn't modify original file and I don't know if Typescript works in the same way as Babel. - babel transform plugins take
<Trans>
tags andi18n.t
calls and transform them into low-level API calls. Since there're no transform plugins for typescript which would do the same, typescript users have to use low-level API directly. - plugin doesn't check imports - Trans component and i18n object might be aliased
Once the plugin is finish, it can be easily hooked to CLI:
import extract from "@lingui/typescript-extract-messages"
const extractor: ExtractorType = {
...
extract(filename, targetDir) {
extract(filename, { localeDir: targetDir })
}
}
Goals
- All tests must pass (should be the same test suit as for
babel-extract-messages
plugin or at least very similar). Remove typescript plugin from ignored modules inscripts/jest/config.unit.js
to run the test suit. - Check that plugin works on Test project (provided by @papoola)