Skip to content

Commit 8c7c535

Browse files
committed
refactor: extract translator options
1 parent 3afae89 commit 8c7c535

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

packages/runtime-core/src/i18n.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ export type TranslationKey<T extends { [key: string]: unknown }, Key = keyof T>
2828
/** @public */
2929
export type LanguageChangeHandler = (this: void, language: Language) => void;
3030

31+
/** @public */
32+
export type TranslatorOptions<T extends { [key: string]: unknown }> = {
33+
fallbackLanguage?: Language;
34+
translations: T;
35+
};
36+
37+
/** @public */
3138
export abstract class BaseTranslator<T extends { [key: string]: unknown } = { [key: string]: unknown }> {
3239
protected abstract currentDocumentLanguage: Language | null;
3340
protected abstract fallbackLanguage: Language;
@@ -47,7 +54,7 @@ export class Translator<T extends { [key: string]: unknown }> extends BaseTransl
4754
protected handleLanguageChange: LanguageChangeHandler | null;
4855
protected translations: T;
4956

50-
constructor(options: { fallbackLanguage?: Language; translations: T }) {
57+
constructor(options: TranslatorOptions<T>) {
5158
super();
5259
this.currentDocumentLanguage = null;
5360
this.fallbackLanguage = options.fallbackLanguage ?? 'en';

0 commit comments

Comments
 (0)