code refactoring
This commit is contained in:
@@ -1,28 +1,28 @@
|
||||
// @ts-nocheck
|
||||
import i18n from "../../assets/i18n.yaml";
|
||||
import i18n from "../../assets/i18n.yaml"
|
||||
|
||||
export default class I18nBuilder {
|
||||
private language: string;
|
||||
private textMap = i18n.languages;
|
||||
private language: string
|
||||
private textMap = i18n.languages
|
||||
|
||||
constructor(language: string) {
|
||||
this.language = language;
|
||||
this.language = language
|
||||
}
|
||||
|
||||
getLanguage(): string {
|
||||
return this.language;
|
||||
return this.language
|
||||
}
|
||||
|
||||
setLanguage(language: string): void {
|
||||
this.language = language;
|
||||
this.language = language
|
||||
}
|
||||
|
||||
t(key: string): string {
|
||||
const map = this.textMap[this.language]
|
||||
if (map) {
|
||||
const translation = map[key];
|
||||
return translation ?? 'caption not defined';
|
||||
const translation = map[key]
|
||||
return translation ?? 'caption not defined'
|
||||
}
|
||||
return 'caption not defined';
|
||||
return 'caption not defined'
|
||||
}
|
||||
}
|
||||
@@ -20,10 +20,13 @@ export class RPCClient {
|
||||
}
|
||||
|
||||
private sendHTTP<T>(req: RPCRequest) {
|
||||
return new Promise<RPCResponse<T>>((resolve, reject) => {
|
||||
return new Promise<RPCResponse<T>>((resolve) => {
|
||||
fetch(getHttpRPCEndpoint(), {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(req)
|
||||
body: JSON.stringify({
|
||||
id: this.incrementSeq(),
|
||||
...req
|
||||
})
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then(data => resolve(data))
|
||||
@@ -59,6 +62,7 @@ export class RPCClient {
|
||||
|
||||
public running() {
|
||||
this.send({
|
||||
id: this.incrementSeq(),
|
||||
method: 'Service.Running',
|
||||
params: [],
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user