Skip to content

lingui extract to handle customized Trans component #2160

@ippeiukai

Description

@ippeiukai

Is your feature request related to a problem? Please describe.

I have a customized Trans component.
npx -- lingui extract does not extract messages from their direct usage.

import { Trans } from '~i18n';

Macro usage works fine. runtimeConfigModule is configured as follows:

  runtimeConfigModule: {
    i18n: ['~i18n', 'i18n'],
    Trans: ['~i18n', 'Trans'],
  },

Describe proposed solution

lingui extract should support Trans component imported from other locations than hardcoded @lingui/react.

In addition to Trans from @lingui/react, lingui cli can pick up runtimeConfigModule.Trans or something similar from config file.

Describe alternatives you've considered

lingui extract could pick up any <Trans /> usage regardless of import path, like it does with i18n._(). It would break backward compatibility, however.

Additional context

@lingui/react is hardcoded here:

.referencesImport("@lingui/react", "Trans")

Is runtimeConfigModule ignored by lingui-macro plugin when ran from lingui extract cli?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions