Skip to content

Commit

Permalink
fix: I18N could be optional when providing single locale (#1129)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed Dec 19, 2023
1 parent 658ddb8 commit 94fcfce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { AureliaViewOutput, ViewModelBindableInputData } from '../models/index';
import { Constructable, CustomElement, IAurelia, singleton } from 'aurelia';


(IAurelia as any).test = 'import 1';

@singleton()
Expand Down
9 changes: 5 additions & 4 deletions packages/aurelia-slickgrid/src/services/translater.service.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { TranslaterService as UniversalTranslateService } from '@slickgrid-universal/common';
import { I18N } from '@aurelia/i18n';
import { optional } from 'aurelia';

/**
* This is a Translate Service Wrapper for Slickgrid-Universal monorepo lib to work properly,
* it must implement Slickgrid-Universal TranslaterService interface to work properly
*/
export class TranslaterService implements UniversalTranslateService {
constructor(@I18N private readonly i18n: I18N) { }
constructor(@optional(I18N) @I18N private readonly i18n: I18N) { }

/**
* Method to return the current language used by the App
* @return {string} current language
*/
getCurrentLanguage(): string {
return this.i18n.getLocale();
return this.i18n?.getLocale();
}

/**
Expand All @@ -22,7 +23,7 @@ export class TranslaterService implements UniversalTranslateService {
* @return {Promise} output
*/
async use(newLang: string): Promise<any> {
return this.i18n.setLocale(newLang);
return this.i18n?.setLocale(newLang);
}

/**
Expand All @@ -31,6 +32,6 @@ export class TranslaterService implements UniversalTranslateService {
* @return {string} translated value
*/
translate(translationKey: string): string {
return this.i18n.tr(translationKey);
return this.i18n?.tr(translationKey);
}
}

0 comments on commit 94fcfce

Please sign in to comment.