GithubHelp home page GithubHelp logo

hjylewis / babel-plugin-inline-i18n-messages Goto Github PK

View Code? Open in Web Editor NEW
23.0 23.0 2.0 3.28 MB

A tooling-agnostic i18n message inlining plugin for babel

Home Page: https://npm.im/babel-plugin-inline-i18n-messages

License: MIT License

JavaScript 100.00%
babel bundle code-splitting formatjs i18n inline internationalization localization messages react-intl split

babel-plugin-inline-i18n-messages's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar hjylewis avatar willross avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

babel-plugin-inline-i18n-messages's Issues

Dependabot can't resolve your JavaScript dependency files

Dependabot can't resolve your JavaScript dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Error whilst updating @formatjs/cli in /package-lock.json:
No matching version found for intl-messageformat-parser@^5.0.7.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Multilingual bundles

I have a question regarding this repo? If i have 5 supported langugaes, then would there be 5 different js bundles or chunks created?

Error if message is ALLCAPS

If a message is in all caps (e.g. "FAQ") or a message ID is in all caps/number (e.g. "404") the following error is thrown by Babel:

Error: @babel/template placeholder "FAQ": Expected string substitution

While changing message ID's to something else is not a problem, messages themselves shouldn't trigger such an error.

Is there a way to fix that?

Revisit "file" "source" API

Should the configuration accept functions instead of paths to modules?

Should we pick "file" or "source" for "addMessagesSource" etc? What about "path"?

SSR / Next.js example

Hi there!

What you are doing is amazing and you are solving a very big problem for apps that have a lot of strings. I'm really glad this exists now!

However, from the current examples it's not immediately obvious how this would work with isomorphic apps, using Next.js for example.

So if you could provide some pointers or maybe create a Next.js example, you'd save someone's life :)

Thanks!

[Question] Is there a way to extract keys from custom message declarations?

This is not a problem with this library. I see that it is using @formatjs/cli which is in turn using babel-plugin-react-intl to extract keys for each page, and babel-plugin-react-intl only extracts keys for defineMessages(), defineMessage(), and <FormattedMessage> imported from react-int and declared according to react-intl's API.

However, many developers, myself included, find those declarations overly verbose and use something like

// translate.js

export default const t = (id) => ( <FormattedMessage id={id} /> )

and then elsewhere in code

// app.js

import t from "./translate"
...
<span>{t("hello")}</span>

And so those declarations don't get extracted.

So the question is - is there a way to extract such declarations?

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.