tweak client

This commit is contained in:
syuilo
2022-06-21 17:55:38 +09:00
parent a6fff86099
commit f880d0631c
8 changed files with 175 additions and 167 deletions

View File

@@ -11,13 +11,13 @@ export class I18n<T extends Record<string, any>> {
// string にしているのは、ドット区切りでのパス指定を許可するため
// なるべくこのメソッド使うよりもlocale直接参照の方がvueのキャッシュ効いてパフォーマンスが良いかも
public t(key: string, args?: Record<string, string>): string {
public t(key: string, args?: Record<string, string | number>): string {
try {
let str = key.split('.').reduce((o, i) => o[i], this.ts) as unknown as string;
if (args) {
for (const [k, v] of Object.entries(args)) {
str = str.replace(`{${k}}`, v);
str = str.replace(`{${k}}`, v.toString());
}
}
return str;