Dojo custom build with NLS / localisation

谁说胖子不能爱 提交于 2019-12-05 22:49:36

问题


I have a problem implementing a cross domain custom build in Dojo. The situation is as follows: i have a pretty large application, with a good number of localisation bundles, so basicly the directory structures is like
core\ (my module)
nls\
fr\
en\
....
When building my module the result is a big core.js/core.xd.js file, which, bien sur, does not contain the localisations. In the localisation nls directories (en/fr/etc) i find after the build each bundle builded/minified, and a bigger file for each language, core_fr.js/core_en.fs, which contains only Dojo/Dijit related strings.

so my build script is

            layers: [
            {
    resourceName: "core",
            name: "../core/trusted.js",
            dependencies: [
                      "dojo.i18n",
                      //data
                      "dojox.data.JsonRestStore",
                      "dojox.data.XmlStore",
                      "dojox.rpc.Service",
                      "dojox.form.FileInput",
                       ...
                      "core.controller.Fusebox"                        
],
                  prefixes: [
                ["dijit","../dijit"],
            ["dojox","../dojox"],
                    ["core", "../core"]
                  ]

In the core.controller.Fusebox class i try to load 1 nls

dojo["requireLocalization"]("core", "FuseboxContent");

here it will die, however with

availableFlatLocales is undefined
[Break on this error] var locales = availableFlatLocales.split(",");\r\n

My config in the html file is :

// version build
  var djConfig = {
    baseUrl: 'https://..../',
    modulePaths: { 'core': 'core'},
    useXDomain: true,
    xdWaitSeconds: 10,
    parseOnLoad: true,
    afterOnLoad: true,
//  debugAtAllCosts: true,
    isDebug: true,
    locale: "fr"
  };

and then

<script type="text/javascript" src="http://xd.woopic.com/dojoroot/1.3.2-xd/dojo/dojo.xd.js.uncompressed.js"></script> 
<script type="text/javascript" src="https://..../core/trusted.js.uncompressed.js"></script>  

I used the uncompressed for debug, of course. The problem is that, on runtime, Dojo tries to load my bundles and can not find them, and i would like to embed them in my layer file, so no extra loads will be required. Can this be achieved? And while we're at it, are there any working sites/examples with cross domain localisations? UPDATE: i continued my analysis and the problem seems to lay in the fact that i am dynamicaly loading nls, so the build parser can not find the requireLocalization() calls. Therefore the project nls file contains only dojo/dijit related content. However, i added a few bundle loads in a dummy file, and the content of core/nls is still ignored by the builder.

Thanks for any info, i am pretty much at the end of my searches, there isn't much on the net on this subject.


回答1:


I had a similar issue a few days ago. First of all, you can get around the error by setting the available locales as the 4th parameter of the requireLocalization call.

e.g.

dojo.requireLocalization("core", "FuseboxContent", null, "en,fr");

though you should not have to do that.

Did you try including the localization as follows?

dojo.requireLocalization("core", "FuseboxContent"); // and not dojo["require..."]


来源:https://stackoverflow.com/questions/1644104/dojo-custom-build-with-nls-localisation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!