feat: add getLocale api #248
This commit is contained in:
@@ -128,3 +128,13 @@ const {
|
||||
footer: string
|
||||
} = await instance.command.getText()
|
||||
```
|
||||
|
||||
## getLocale
|
||||
|
||||
功能:Get current locale
|
||||
|
||||
用法:
|
||||
|
||||
```javascript
|
||||
const locale = await instance.command.getLocale()
|
||||
```
|
||||
@@ -128,3 +128,13 @@ const {
|
||||
footer: string
|
||||
} = await instance.command.getText()
|
||||
```
|
||||
|
||||
## getLocale
|
||||
|
||||
功能:获取当前语言
|
||||
|
||||
用法:
|
||||
|
||||
```javascript
|
||||
const locale = await instance.command.getLocale()
|
||||
```
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user