Giter Club home page Giter Club logo

Comments (2)

thekip avatar thekip commented on May 23, 2024

@krzkaczor hey, this is intentional design decision. During development (NODE_ENV==development) default messages included in bundle with a compiler. But for production build all non-essential properties and message compiler dropped. There is literally nothing to fallback to in production build.

The good solution would be to add an extract step just before running a production build in your CI pipeline.
I also recommend to use extract to template instead of normal extract.

Extract to template creating a "template" which you can then add to git ignore because it's an artifact produced from your code, such as sourcemaps. All cli tooling is aware of templates and will use it to fallback in case of message not found in original catalog.

I also recommend to use vite loader or webpack loader for catalogs to avoid explicit compilation step. So full solution would be:

  • Use vite plugin or webpack loader and load your ".po" catalogs directly, example
  • Add lingui extract-template just before build your application
    // package.json
        "build": "yarn extract-messages && next build",
        "extract-messages": "lingui extract-template",
  • Use any TMS you want to manage and merge translations. The mimimal requirement is to support ICU message syntax and PO format. We use crowdin and it works fine.
  • With lingui extract-template you load template file (for po-format it is template.pot) into TMS and download catalogs with translations (bunch of {lang}.po files). Even without TMS you can use POEditor desktop app to handle workflow with templates.

Note: As you see i also recommend to use Po format. I know that many developers in the beginning deciding to go with JSON because they think it would be easier to start with. But there are no advantages of json over PO files, because both of them you need to compile before use, but PO file will provide way better developer and translation experience than json.

from js-lingui.

krzkaczor avatar krzkaczor commented on May 23, 2024

@thekip Thank you for this detailed explanation. Helps a lot.

hey, this is intentional design decision. During development (NODE_ENV==development) default messages included in bundle with a compiler. But for production build all non-essential properties and message compiler dropped. There is literally nothing to fallback to in production build.

The good solution would be to add an extract step just before running a production build in your CI pipeline.
I also recommend to use extract to template instead of normal extract.

It would be great to mention this somewhere in the docs.

from js-lingui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.