Skip to content

Commit

Permalink
Merge pull request #296 from lcetinapta/fix-for-295
Browse files Browse the repository at this point in the history
Fix for #295, upgraded i18next to v14.0.1
  • Loading branch information
EisenbergEffect authored Feb 12, 2019
2 parents 1f17f9d + 15c6dd2 commit 8c5437e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
19 changes: 14 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
"aurelia-pal": "^1.3.0",
"aurelia-templating": "^1.8.2",
"aurelia-templating-resources": "^1.7.1",
"i18next": "^11.6.0"
"i18next": "^14.0.1"
}
},
"dependencies": {
Expand All @@ -125,7 +125,7 @@
"aurelia-pal": "^1.3.0",
"aurelia-templating": "^1.8.2",
"aurelia-templating-resources": "^1.7.1",
"i18next": "^11.6.0"
"i18next": "^14.0.1"
},
"devDependencies": {
"@types/i18next": "^8.4.5",
Expand Down
9 changes: 4 additions & 5 deletions src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ export class I18N {
}

public async setup(options?: AureliaEnhancedOptions & i18next.InitOptions) {
const defaultOptions = {
const defaultOptions: AureliaEnhancedOptions & i18next.InitOptions = {
skipTranslationOnMissingKey: false,
compatibilityAPI: "v1",
compatibilityJSON: "v1",
lng: "en",
attributes: ["t", "i18n"],
Expand All @@ -50,7 +49,7 @@ export class I18N {
};

this.i18nextDeferred = new Promise((resolve, reject) => {
this.i18next = this.i18next.init(options || defaultOptions, (err) => {
this.i18next = this.i18next.createInstance(options || defaultOptions, (err) => {
if (err) {
reject(err);
}
Expand All @@ -71,7 +70,7 @@ export class I18N {
return this.i18nextDeferred;
}

public setLocale(locale: string): Promise<i18next.TranslationFunction> {
public setLocale(locale: string): Promise<i18next.TFunction> {
return new Promise((resolve, reject) => {
const oldLocale = this.getLocale();
this.i18next.changeLanguage(locale, (err, tr) => {
Expand Down Expand Up @@ -120,7 +119,7 @@ export class I18N {
return new this.Intl.DateTimeFormat(locales || this.getLocale(), options);
}

public tr(key: string | string[], options?: i18next.TranslationOptions<object>) {
public tr(key: string | string[], options?: i18next.TOptions<object>) {
let fullOptions = this.globalVars;

if (options !== undefined) {
Expand Down
2 changes: 1 addition & 1 deletion src/t/t-value-converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class TValueConverter {

constructor(private service: I18N) { }

public toView(value: any, options?: i18next.TranslationOptions<object>) {
public toView(value: any, options?: i18next.TOptions<object>) {
return this.service.tr(value, options);
}
}

0 comments on commit 8c5437e

Please sign in to comment.