Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18n and code splitting #5433

Closed
stereobooster opened this issue Oct 14, 2018 · 3 comments
Closed

i18n and code splitting #5433

stereobooster opened this issue Oct 14, 2018 · 3 comments
Labels

Comments

@stereobooster
Copy link
Contributor

stereobooster commented Oct 14, 2018

Is this a bug report?

No, rather a feature request.

i18n

There are ways to extract keys for internationalisation, like:

Those methods can extract keys, and place it in either:

  • one big file
  • one file pre each JS files

Code splitting

CRA supports code splitting out of the box 👍, I would also like to split i18n the same way as JS splitted:

Loadable.Map({
  loader: {
    Bar: () => import(/* webpackChunkName: Bar */ './Bar'),
    i18n: () => fetch(`./i18n/${lang}/bar.json`).then(res => res.json()),
  },
  render(loaded, props) {
    let Bar = loaded.Bar.default;
    let i18n = loaded.i18n;
    return <Bar {...props} i18n={i18n}/>;
  },
});

Bar can contain other components (with static imports and i18n keys), for example Foo. So Bar.xxxx.chunk.js can require i18n keys for Foo and for Bar or it can happen that Foo, will be splitted in common.xxxx.chunk.js.

It would be nice to have Bar.xxxx.chunk.json and common.xxxx.chunk.json with i18n keys so appropriate translation files can be generated.

Obviously CRA should not lock-in users with some exact i18n library, but rather we can look into providing low level APIs so other libraries can reuse it. This idea still miss some details, for example, how i18n would work in development environment and maybe other.

Related tickets:

@Guillerbr
Copy link

ok tanks

@stale
Copy link

stale bot commented Nov 13, 2018

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Nov 13, 2018
@stale
Copy link

stale bot commented Nov 19, 2018

This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.

@stale stale bot closed this as completed Nov 19, 2018
@lock lock bot locked and limited conversation to collaborators Jan 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants