Skip to content

Commit

Permalink
fix(supercomponent.billings): fix getTranslation
Browse files Browse the repository at this point in the history
ref: MANAGER-11620

Signed-off-by: Nicolas BAPTISTA <[email protected]>
  • Loading branch information
Kranysys committed Jul 26, 2023
1 parent ed1ee1b commit b1601fa
Showing 1 changed file with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ export class MscBillingTile implements IMscBillingTile {

@State() private tabIndex = 0;

@State() i18nLoaded = false;

@State() serviceId: string;

@State() creationDate: string;
Expand Down Expand Up @@ -117,16 +115,20 @@ export class MscBillingTile implements IMscBillingTile {
});
}

getTranslation(key: string, options?: Record<string, any>): string {
if (!this.i18nLoaded) return key;
console.info('options : ', options);
return 'To replace'; /* A remplacer car on peut faire sans le I18n instance */
// const translation = this.i18nInstance.t(key, {
// ...options,
// lng: this.language,
// });
// if (!translation) return key;
// return translation;
getTranslation(key: string, options?: Record<string, string>): string {
let translation = this.localStrings[key] || '';

if (options) {
Object.keys(options).forEach((option) => {
const placeholder = `{{ ${option} }}`;
translation = translation.replace(
new RegExp(placeholder, 'g'),
options[option],
);
});
}

return translation;
}

async fetchServiceId() {
Expand Down

0 comments on commit b1601fa

Please sign in to comment.