【发布时间】:2016-03-30 18:05:06
【问题描述】:
我目前正在开发一个 Aurelia 项目(像 Angular2 这样的网络框架)。 我按照他们的github account 上的指南进行操作,但遇到了问题。
首先,浏览器返回给我这个错误:GET http://localhost:9000/src/locale/nl/translation.json?_=1450946571510 404 (Not Found)
其次,我在我的应用程序中使用了两种语言:荷兰语 (nl-BE) 和法语 (fr-BE)。
我的文件夹结构如下所示:
src (inside root)
.. locale
..... fr-BE
........ translation.json
..... nl-BE
........ translation.json
这是我的完整 main.js 文件的样子:
import 'bootstrap';
import {I18N} from 'aurelia-i18n';
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging()
.globalResources('converters/dateFormat')
.plugin('components/index')
.plugin('plugins/index')
.plugin('aurelia-i18n', (instance) => {
instance.setup({
resGetPath: 'src/locale/__lng__/__ns__.json',
lng: 'nl-BE',
attributes: ['t', 'i18n'],
getAsync: true,
sendMissing: false,
fallbackLng: 'fr-BE',
debug: false
});
});
aurelia.start().then(a => a.setRoot());
}
我正在尝试设置一个 hello world,我的视图和视图模型设置如下:
import {inject} from 'aurelia-framework';
import {I18N} from 'aurelia-i18n';
@inject(I18N)
export class EntryDetails {
constructor(i18n){
this.i18n = i18n;
this.i18n.setLocale('nl-BE').then(() => console.log('test'));
}
}
我的看法:
<template>
<span t="hello"></span> <span t="world"></span>
</template>
问题不在于它不起作用。问题是我收到一个错误,指出我的文件夹 nl 在我的 locale 文件夹中丢失。但我从来没有在任何地方指定过..
【问题讨论】:
标签: internationalization aurelia i18next