Andreas Köberle
Andreas Köberle

Reputation: 110922

Load only one language with require.js i18n

Is there a way to load only one language with the require.js i18n plugin?

With the default settings, the default language is always loaded, and then the language with the locale of your browser is also loaded.

I'm looking for a solution in which the default language will not be compiled in the app.js, but loaded after when require.js has checked the browser locale.

Upvotes: 7

Views: 1778

Answers (1)

Andreas Köberle
Andreas Köberle

Reputation: 110922

Ok I've got it. You have to set set root to false in the base i18n.js file:

define({
  "root": false,
  "de": true,
  "en": true
});

In this case only the above json will be rendered in your optimized version. And after loading require.js decide which langauge to load. Note that you lost the default language and you have to make sure to set all properties in all your languages.

Upvotes: 6

Related Questions