Dojo定制与NLS /本地化 [英] Dojo custom build with NLS / localisation

查看:250
本文介绍了Dojo定制与NLS /本地化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Dojo中实现跨域自定义构建时遇到问题。
情况如下:我有一个非常大的应用程序,有很多本地化捆绑,所以基本上目录结构是像
core \\(我的模块)

nls\

fr \

en \

....

当构建我的模块时,结果是一个很大的core.js / core.xd.js文件,其中bien sur不包含本地化。在本地化的nls目录(en / fr / etc)中,我发现构建每个bundle之后建立/分解,每个语言的core_fr.js / core_en.fs都有一个更大的文件,它只包含Dojo / Dijit相关的字符串。 p>

所以我的构建脚本是

  layers:[
{
resourceName:core,
name:../core/trusted.js,
依赖关系:[
dojo.i18n,
//数据
dojox.data.JsonRestStore,
dojox.data.XmlStore,
dojox.rpc.Service,
dojox.form.FileInput,
...
core.controller.Fusebox
],
前缀:[
[dijit,../ dijit],
[dojox,../ dojox],
[core,../core]
]

在core.controller.Fusebox类中,我尝试加载1 nls

  dojo [requireLocalization](core,FuseboxContent); 

这里它会死,但是与

  availableFlatLocales未定义
[在此错误中打破] var locales = availableFlatLocales.split(,); \r\\\

我的html文件中的配置是:

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

然后

 code>< script type =text / javascriptsrc =http://xd.woopic.com/dojoroot/1.3.2-xd/dojo/dojo.xd.js.uncompressed.js> < /脚本> 
< script type =text / javascriptsrc =https://..../core/trusted.js.uncompressed.js>< / script>

当然,我使用未压缩的调试。
问题是,在运行时,Dojo尝试加载我的软件包,找不到它,我想将它们嵌入到我的图层文件中,因此不需要额外的加载。
可以实现吗?当我们在这里时,是否有任何工作网站/跨域域名的示例?
更新:我继续我的分析,问题似乎在于我动态地加载nls,所以构建解析器找不到requireLocalization()调用。因此,项目nls文件仅包含dojo / dijit相关内容。但是,我在一个虚拟文件中添加了一些捆绑包,而核心/ nls的内容仍然被构建器忽略。



感谢任何信息,我很漂亮我的搜索结尾很多,这个问题在网上没有多少。

解决方案

我有一个类似的问题几天之前。首先,您可以通过将可用的区域设置设置为requireLocalization调用的第四个参数来解决错误。



例如

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

虽然你不应该这样做。



你尝试包括本地化如下?

  dojo.requireLocalization(core,FuseboxContent); //而不是dojo [require ...] 


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.

解决方案

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..."]

这篇关于Dojo定制与NLS /本地化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆