使用 Aurelia i18n 时出错

error using Aurelia i18n

我正在尝试使用 Aurelia-i18n,但我有点卡在初始配置步骤。到目前为止我已经完成了 (https://github.com/aurelia/i18n#how-to-install-this-plugin),但是当我 运行 我的应用程序时出现此错误:

frameworkConfig.globalResources is not a function

main.js

import {I18N} from 'aurelia-i18n';

export function configure(aurelia) {
  aurelia.use
    .standardConfiguration()
    .developmentLogging()
    .plugin('aurelia-validation')
    .plugin('aurelia-i18n', (instance) => {
      instance.setup({
        resGetPath : 'locale/__lng__/__ns__.json',
        lng : 'en',
        attributes : ['t','i18n'],
        getAsync : true,
        sendMissing : false,
        fallbackLng : 'en',
        debug : false
      });
    });

  aurelia.start().then(a => a.setRoot());
}

locale/en/translation.json

{
  "hello": "hello"
}

我做错了什么?

您可能使用的是旧版本的 Aurelia 框架。

要确定您是否已过时,请打开您的 package.json 并找到此行:

"aurelia-framework": "github:aurelia/framework@^[some version]"

并将您在此处看到的版本与此处的最新版本进行比较:https://github.com/aurelia/framework/releases

您可以使用 jspm 安装最新版本的 Aurelia 模块 - 这个命令可以做到(您可能想从命令中删除一些您不使用的模块):

jspm install aurelia-animator-css aurelia-binding aurelia-bootstrapper aurelia-dependency-injection aurelia-framework aurelia-http-client aurelia-router aurelia-event-aggregator aurelia-history-browser aurelia-loader-default aurelia-loader aurelia-metadata aurelia-route-recognizer aurelia-templating-binding aurelia-templating-resources aurelia-templating-router aurelia-templating aurelia-logging aurelia-task-queue aurelia-history aurelia-path

关注 http://blog.durandal.io/ 以了解 Aurelia 接近 beta/v1.0.0 时的重大更改和最新版本。

此版本宣布了从 globalizeResources 到 globalResources 的更改:http://blog.durandal.io/2015/03/25/aurelia-0-10-0-release-status/