lingui / js-lingui

🌍 📖 A readable, automated, and optimized (3 kb) internationalization for JavaScript
https://lingui.dev
MIT License
4.51k stars 378 forks source link

Allow fallback to a messages defined in the code without compilation #2043

Open timofei-iatsenko opened 1 week ago

timofei-iatsenko commented 1 week ago

ToDo: motivation, related issues

Tasks:

  1. Make configurable strip_non_essential_fields in the SWC plugin from outside. Now it's hardcoded to the ENV variable

    • or introduce new option supress_stripping_message, which will allow stripping context and comment but left message.
  2. Make the same options for Babel macro plugin

  3. Make possible to register MessageCompiler in production, PR: https://github.com/lingui/js-lingui/pull/2035

  4. Write the docs describing all configuration to achieve that.

ilyausorov commented 19 hours ago

Would really appreciate supress_stripping_message because right now I'm having to patch this line in the @lingui/macro package const stripNonEssentialProps = false; // process.env.NODE_ENV == "production" && !opts.extract; to keep the message values available so I can do something like this

const SOME_TEXT = msg`Some text`;

const object = {
       originalValue: SOME_TEXT.message,
       translatedValue: _(SOME_TEXT)
}