update model settings multi lang.

This commit is contained in:
duanfuxiang
2025-06-12 15:19:07 +08:00
parent b20b4f9e19
commit 6501132d80
7 changed files with 63 additions and 22 deletions

View File

@@ -56,7 +56,7 @@ const localeMap: { [k: string]: Partial<typeof en> } = {
const locale = localeMap[moment.locale()];
export function t(str: string): any {
export function t(str: string, params?: Record<string, any>): any {
if (!locale) {
console.error({
plugin: "infio-copilot",
@@ -75,5 +75,12 @@ export function t(str: string): any {
if (result === undefined) return str;
}
// Handle parameter interpolation
if (params && typeof result === 'string') {
return result.replace(/\{([^}]+)\}/g, (match, key) => {
return params[key] !== undefined ? String(params[key]) : match;
});
}
return result;
}