Skip to content

Commit 47ae268

Browse files
committed
adjust Streami18n
1 parent dea0d4f commit 47ae268

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/utils/Streami18n.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ type Options = {
178178
disableDateTimeTranslations?: boolean;
179179
language?: string;
180180
logger?: (msg?: string) => void;
181-
translationsForLanguage?: typeof enTranslations;
181+
translationsForLanguage?: Partial<typeof enTranslations>;
182182
};
183183

184184
type I18NextConfig = {
@@ -358,7 +358,7 @@ export class Streami18n {
358358

359359
translations: {
360360
[key: string]: {
361-
[key: string]: typeof enTranslations | UnknownType;
361+
[key: string]: Partial<typeof enTranslations> | UnknownType;
362362
};
363363
} = {
364364
en: { [defaultNS]: enTranslations },
@@ -452,7 +452,14 @@ export class Streami18n {
452452

453453
if (translationsForLanguage) {
454454
this.translations[this.currentLanguage] = {
455-
[defaultNS]: translationsForLanguage,
455+
[defaultNS]:
456+
this.translations[this.currentLanguage] &&
457+
this.translations[this.currentLanguage][defaultNS]
458+
? {
459+
...this.translations[this.currentLanguage][defaultNS],
460+
...translationsForLanguage,
461+
}
462+
: translationsForLanguage,
456463
};
457464
}
458465

@@ -592,7 +599,7 @@ export class Streami18n {
592599
*/
593600
registerTranslation(
594601
language: string,
595-
translation: typeof enTranslations,
602+
translation: Partial<typeof enTranslations> | UnknownType,
596603
customDayjsLocale?: Partial<ILocale>,
597604
) {
598605
if (!translation) {

0 commit comments

Comments
 (0)