Skip to content

Typescript support #151

Closed
Closed
@tricoder42

Description

@tricoder42

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 and i18n.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

  1. 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 in scripts/jest/config.unit.js to run the test suit.
  2. Check that plugin works on Test project (provided by @papoola)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions