Skip to content

Commit edfb929

Browse files
committed
use json imports to feed languages and remove xhr backend for i18n
1 parent 95dec1d commit edfb929

File tree

6 files changed

+24
-13
lines changed

6 files changed

+24
-13
lines changed

npm-shrinkwrap.json

Lines changed: 10 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@
8585
"aurelia-templating-router": "^1.0.0",
8686
"bootstrap-sass": "^3.3.7",
8787
"font-awesome": "^4.6.3",
88-
"i18next-xhr-backend": "^1.2.0",
8988
"isomorphic-fetch": "^2.2.1",
9089
"jquery": "^3.1.0"
9190
},

src/app/main.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ import '../scss/main.scss';
2121
*/
2222
import { Aurelia, LogManager } from 'aurelia-framework';
2323
import { ConsoleAppender } from 'aurelia-logging-console';
24-
import XHR from 'i18next-xhr-backend';
24+
25+
/**
26+
* Locals i18n imports
27+
*/
28+
import i18nEnglish from './../locales/en.json';
2529

2630
/**
2731
* Aurelia configruation
@@ -44,14 +48,13 @@ export async function configure(aurelia: Aurelia): Promise<void> {
4448
* See: https://github.com/aurelia/i18n
4549
*/
4650
.plugin('aurelia-i18n', (instance) => {
47-
// register backend plugin
48-
instance.i18next.use(XHR);
49-
5051
// adapt options to your needs (see http://i18next.com/docs/options/)
5152
// make sure to return the promise of the setup method, in order to guarantee proper loading
5253
return instance.setup({
53-
backend: { // <-- configure backend settings
54-
loadPath: './locales/{{lng}}.json', // <-- XHR settings for where to get the files from
54+
resources: {
55+
en: {
56+
translation: i18nEnglish
57+
}
5558
},
5659
lng: 'en',
5760
attributes: ['translate', 'i18n'],

typings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"name": "aurelia-skeleton-navigation-webpack",
33
"dependencies": {},
44
"globalDependencies": {
5-
"i18next-xhr-backend": "registry:dt/i18next-xhr-backend#1.2.0+20160921203958",
65
"jasmine": "registry:dt/jasmine#2.5.0+20161003201800",
76
"jquery": "registry:dt/jquery#1.10.0+20160704162008",
87
"lodash": "registry:dt/lodash#4.14.0+20160817155621",

typings_custom/json.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module "*.json" {
2+
let json: any;
3+
export default json;
4+
}

webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ module.exports = function (envArguments) {
180180
require('@easy-webpack/config-html')(),
181181
require('@easy-webpack/config-sass')(configSass(false)),
182182
require('@easy-webpack/config-fonts-and-images')(),
183+
require('@easy-webpack/config-json')(),
183184
require('@easy-webpack/config-global-jquery')(),
184185
require('@easy-webpack/config-global-regenerator')(),
185186
require('@easy-webpack/config-generate-index-html')(configGenerateIndex(true)),

0 commit comments

Comments
 (0)