使用 NLS 构建 Dojo - requireLocalization(..) 失败?

发布于 2024-09-24 12:42:54 字数 2833 浏览 4 评论 0原文

我的问题虽然一开始与这个问题有点相似,但似乎是一个更基本的问题 - 可能表明构建系统中存在错误。我已经为我的 dojo 应用程序创建了一个自定义构建。我现在只构建一层,配置文件脚本/对象如下所示:

dependencies = {
    stripConsole: "all",
    action: "release",
    optimize: "shrinksafe",
    releaseName: "myProject",
    // list of locales we want to expose
    localeList: "en-gb,en-us,de-de",

    layers: [
        {
            // Name: a relative path from the dojo.js in the desination directory.
            name: "../../myProject.js",
            dependencies: [
                "myPackage.MyDataStore",
                // MyWidget depends on a few other widgets, and has its own 
                //   translation files.
                "myPackage.MyWidget"
            ]
        }
    ],

    prefixes: [
        // These paths are relative to the location of dojo.js
        [ "dijit", "../dijit" ],
        [ "dojox", "../dojox" ],
        [ "myPackage", "../../../src/myPackage" ]
    ]
}

当我使用该描述运行构建时,它会在以下目录结构中输出文件:

release/
release/myProject/
release/myProject/dijit/
                       ... dijit ...
release/myProject/dojo/
                      ... dojo ...
release/myProject/dojox/
                       ... dojox ...
release/myProject/myPackage/
                           ... my custom package ...
release/nls/
           myProject_en-us.js
           myProject_de.js
           etc..
../myproject.js
../myProject.js.uncompressed.js

最后,在我的测试 HTML 页面中 - 我有以下内容:

<script type="text/javascript">
    var djConfig = {
        debug: true,
        parseOnLoad: false,
        modulePaths: { // paths to directories in relation to dojo's location.... hurr.
            'myPackage': '../myPackage',
            'dojox':    '../dojox',
            'dijit':    '../dijit'
        }
    };
</script>
<script type="text/javascript" src="./release/myProject/dojo/dojo.js.uncompressed.js"></script>
<script type="text/javascript" src="./release/myProject.js.uncompressed.js"></script>
<script type="text/javascript">
dojo.addOnLoad(function(){
    dojo.require('myPackage.MyDataStore');
    dojo.require('myPackage.MyWidget');

    var store = new myPackage.MyDataStore();
    var widget = new myPackage.MyWidget({
        store: store
    }, dojo.byId('testWidget'));

    widget.startup();
});
</script>

但不幸的是,Firebug 对我吐露了这一点:

Bundle not found: MyWidget in myPackage , locale=en-us

我认为正在发生的事情

我已经追踪了导致上述错误的一些代码,看起来像是 dojo.i18n._preloadLocalizations() 调用文件末尾的 ./release/nls 实际上并未从 ./release/nls 加载正确的 nls 文件。

知道如何解决这个问题,而不需要手动包含带有

My question, while at first somewhat similar to this one, seems to be a more basic question - and might be signaling a bug in the build system. I've created a custom build for my dojo application. I only build one layer right now, here's what the profile script/object looks like:

dependencies = {
    stripConsole: "all",
    action: "release",
    optimize: "shrinksafe",
    releaseName: "myProject",
    // list of locales we want to expose
    localeList: "en-gb,en-us,de-de",

    layers: [
        {
            // Name: a relative path from the dojo.js in the desination directory.
            name: "../../myProject.js",
            dependencies: [
                "myPackage.MyDataStore",
                // MyWidget depends on a few other widgets, and has its own 
                //   translation files.
                "myPackage.MyWidget"
            ]
        }
    ],

    prefixes: [
        // These paths are relative to the location of dojo.js
        [ "dijit", "../dijit" ],
        [ "dojox", "../dojox" ],
        [ "myPackage", "../../../src/myPackage" ]
    ]
}

When I run a build with that description it outputs files in the following directory structure:

release/
release/myProject/
release/myProject/dijit/
                       ... dijit ...
release/myProject/dojo/
                      ... dojo ...
release/myProject/dojox/
                       ... dojox ...
release/myProject/myPackage/
                           ... my custom package ...
release/nls/
           myProject_en-us.js
           myProject_de.js
           etc..
../myproject.js
../myProject.js.uncompressed.js

Finally, in my test HTML page - I've got the following:

<script type="text/javascript">
    var djConfig = {
        debug: true,
        parseOnLoad: false,
        modulePaths: { // paths to directories in relation to dojo's location.... hurr.
            'myPackage': '../myPackage',
            'dojox':    '../dojox',
            'dijit':    '../dijit'
        }
    };
</script>
<script type="text/javascript" src="./release/myProject/dojo/dojo.js.uncompressed.js"></script>
<script type="text/javascript" src="./release/myProject.js.uncompressed.js"></script>
<script type="text/javascript">
dojo.addOnLoad(function(){
    dojo.require('myPackage.MyDataStore');
    dojo.require('myPackage.MyWidget');

    var store = new myPackage.MyDataStore();
    var widget = new myPackage.MyWidget({
        store: store
    }, dojo.byId('testWidget'));

    widget.startup();
});
</script>

But unfortunately, Firebug spits this out at me:

Bundle not found: MyWidget in myPackage , locale=en-us

What I Think is Happening

I've traced through some of the code leading up to the above error and it seems like the dojo.i18n._preloadLocalizations() call at the end of the file doesn't actually load in the correct nls file from ./release/nls.

Any idea how to fix this without resorting to manually including the nls files with <script> tags?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

﹏半生如梦愿梦如真 2024-10-01 12:42:54

这是 dojo 的一个 bug,你不应该在层名称中使用“..”,以免生成 NLS 包。

请参考http://bugs.dojotoolkit.org/ticket/5225

It's a bug of dojo, you should not use '..' in your layers name in case it will generate a NLS package.

please refer to http://bugs.dojotoolkit.org/ticket/5225

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文