Skip to content

Commit

Permalink
fix: wait for language to be loaded before update
Browse files Browse the repository at this point in the history
  • Loading branch information
cpaulve-1A committed Jul 16, 2024
1 parent d90945b commit ec4e5c9
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApplicationRef, Injectable } from '@angular/core';
import { TranslateCompiler } from '@ngx-translate/core';
import { lastValueFrom, Subscription } from 'rxjs';
import {firstValueFrom, lastValueFrom, Subscription} from 'rxjs';
import { LocalizationService } from '../tools';
import type { TranslateMessageFormatLazyCompiler } from '../core';

Expand Down Expand Up @@ -65,9 +65,10 @@ export class OtterLocalizationDevtools {
* @param keyValues key/values to update
* @param language if not provided, the current language value
*/
public updateLocalizationKeys(keyValues: { [key: string]: string }, language?: string): void | Promise<void> {
public async updateLocalizationKeys(keyValues: { [key: string]: string }, language?: string) {
const lang = language || this.getCurrentLanguage();
const translateService = this.localizationService.getTranslateService();
await firstValueFrom(translateService.getTranslation(lang));
Object.entries(keyValues).forEach(([key, value]) => {
translateService.set(key, value, lang);
});
Expand Down

0 comments on commit ec4e5c9

Please sign in to comment.