-
Notifications
You must be signed in to change notification settings - Fork 52
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
Setting locale manually in r.js build is not working #18
Comments
Do you have an example project I can try, to see the problem? That will also help me to construct a test case to make sure it stays fixed in the future. |
I've got a similar problem. When I'm in development mode i set the locale in the config.js file like this
very interesting is that the following piece of code wont work:
my root labels files looks like this:
Everything is fine, but when I try to build a optimized version with the r.js optimizer then i got the following message:
in my build.config.file I also inlcude an empty path for the nls folder
I see the point with the valid JSON, but I'm wondering how to built a minified version of my application (with and without including the labels/locale files into the built, depending on the env web or mobile) and still keep going with the localstorage method to store the current locale variable. Every tip for a solution is appreciated!! |
requirejs.config can be called multiple times, with the most recent call taking priority. For mainConfigFile it only finds the first requirejs.config call in a build, so you could do something like this: requirejs.config({
config: {
i18n: {
locale: 'en_US'
},
}
});
var storedLocaled = localStorage.getItem('locale');
if (storedLocale) {
requirejs.config({
config: {
i18n: {
locale: storedLocale
},
}
});
}
// Then load the app
require(['app'], ...); This assumes that the first requirejs.config() call does not specify "deps" in it, the loading should be triggered after the second requirejs.config() call. |
thx it works now in the development mode! but i still having trouble combining/minifying the project. I am not sure which way to go and which one is the better solution (and as well not how to do this :D):
For example I tried the following settings in my build.config.file:
but then when i try to load the app, i got the following error:
How i have to config the build-file to not include the labels-files into the build and load them separately? Update The build process works when i change the optimize-modus from uglify2 to none. also uglify doesnt work. but if this doesnt work, where is the point of minifying :-( ... does anybody have an idea what could cause the problem here? |
I have the same issue. My build config sets locale parameter as below:
A typical i18n module would contain:
My en-us module then returns:
However, when it comes to running the r.js optimizer, both files are included in the compiled source and the browser settings are used to determine the locale - this is not what I want. As I pass the locale config value into r.js optimizer I am expecting it to only compile the Any support would be helpful |
+1 |
1 similar comment
+1 |
I'm developing an application using i18n plugin. And I'm setting locale manually in main.js file according to user preferences. Like this:
And it works pretty well. But I can't set locale manually for r.js build.
According to documentation I'm setting locale in r.js config file and r.js should inline following i18n resources into the build:
And it works, i18n resources are actually inlined into the build file. But i18n plugin still detects locale automatically. So nothing works if detected locale and bundled resources don't matched. It happens because i18n plugin is trying to load not existing i18n resources for automatically detected locale.
The text was updated successfully, but these errors were encountered: