feat: add getLocale api #248

This commit is contained in:
Hufe921
2023-08-17 21:32:16 +08:00
parent 8f145e251b
commit fef6ddf7a8
5 changed files with 30 additions and 0 deletions
+2
View File
@@ -86,6 +86,7 @@ export class Command {
public getRangeContext: CommandAdapt['getRangeContext']
public getPaperMargin: CommandAdapt['getPaperMargin']
public getSearchNavigateInfo: CommandAdapt['getSearchNavigateInfo']
public getLocale: CommandAdapt['getLocale']
constructor(adapt: CommandAdapt) {
// 全局命令
@@ -182,5 +183,6 @@ export class Command {
this.getCatalog = adapt.getCatalog.bind(adapt)
this.getPaperMargin = adapt.getPaperMargin.bind(adapt)
this.getSearchNavigateInfo = adapt.getSearchNavigateInfo.bind(adapt)
this.getLocale = adapt.getLocale.bind(adapt)
}
}
+4
View File
@@ -1837,6 +1837,10 @@ export class CommandAdapt {
this.i18n.setLocale(payload)
}
public getLocale(): string {
return this.i18n.getLocale()
}
public getCatalog(): Promise<ICatalog | null> {
return this.workerManager.getCatalog()
}
+4
View File
@@ -17,6 +17,10 @@ export class I18n {
this.langMap.set(locale, <ILang>mergeObject(sourceLang || zhCN, lang))
}
public getLocale(): string {
return this.currentLocale
}
public setLocale(locale: string) {
this.currentLocale = locale
}