Welcome to dojo-webpack-plugin Discussions! #317
Replies: 4 comments 18 replies
-
I have a question regarding dojo/i18n. The default 'en-us' locale works fine. Adding and using another locale is failing in findModule. The reason is that although req.absMids has the entry key 'nls/cloudCenterStringResource' and value of "./assets/js/nls/cloudCenterStringResource.js", which is correct, but for some reason the japanese translation key is 'assets/js/nls/ja-jp/cloudCenterStringResource', which is wrong. It should be 'nls/ja-jp/cloudCenterStringResource'. My question is what in the webpack config file controls what the absMids key would be? Using the debugger, I changed the value of the key from 'assets/js/nls/ja-jp/cloudCenterStringResource' to 'nls/ja-jp/cloudCenterStringResource' and the app worked correctly for the japanese locale. |
Beta Was this translation helpful? Give feedback.
-
If your root bundle is Also, your root bundle should indicate which locales you have bundles for. For example: define({
root: {
greeting: "Hello, world!"
},
"ja-jp": true,
}); See https://dojotoolkit.org/reference-guide/1.9/dojo/i18n.html |
Beta Was this translation helpful? Give feedback.
-
The code that generates the absMids for the i18n modules can be found here: https://github.com/OpenNTF/dojo-webpack-plugin/blob/master/loaders/dojo/i18n/index.js. If you want to dive on this, I'd start there. Otherwise, if you provide a test case, I can take a look. |
Beta Was this translation helpful? Give feedback.
-
I'd like to summarize the behavior I've observed. You can refer to the debugging session details above for a concrete example. It then reads this default bundle and sees that there are locale-specific bundles ('ja-jp') in this case, because the default bundle is an object with properties "root" and "ja-jp": true. It now creates an absMid for the locale-specific bundle but, it creates it as "./assets/js/nls/ja-jp/cloudCenterStringResource", which is the correct location of the resource bundle file but, it is not how the app requests it. When the browser's locale is set to "ja-jp" and requests the page, the request comes in as "dojo/i18n!nls/ja-jp/cloudCenterStringResource". This gets broken up into "dojo/i18n" and "nls/ja-jp/cloudCenterStringResource". I proposed a change in the loaders/i18n/index.js code to produce "nls/ja-jp/cloudCenterStringResource", instead of "./assets/js/nls/ja-jp/cloudCenterStringResource". If possible, please take a look. You mention that dojo/i18n works for you. Is this true even of non-default locales? I figure either our code configuration has an issue or, the case of non-default locale doesn't work. It seems like it's standard behavior for dojo/i18n to request a non-default (or any) bundle as "dojo/i18n!nls/${loc}/${bundlename}" so, I don't see how generating an absMid value of anything other than starting with "nls/${loc}/" would work. Thanks for your help. |
Beta Was this translation helpful? Give feedback.
-
👋 Welcome!
We’re using Discussions as a place to connect with other members of our community. We hope that you:
build together 💪.
To get started, comment below with an introduction of yourself and tell us about what you do with this community.
Beta Was this translation helpful? Give feedback.
All reactions