feat(localization): add model description translations and enhance UI text across multiple languages

This commit is contained in:
Will Miao
2025-08-31 10:12:54 +08:00
parent 6acccbbb94
commit 867ffd1163
15 changed files with 313 additions and 30 deletions

View File

@@ -2,6 +2,26 @@
* i18n utility functions for safe translation handling
*/
/**
* Synchronous translation function.
* Assumes window.i18n is ready.
* @param {string} key - Translation key
* @param {Object} params - Parameters for interpolation
* @param {string} fallback - Fallback text if translation fails
* @returns {string} Translated text
*/
export function translate(key, params = {}, fallback = null) {
if (!window.i18n) {
console.warn('i18n not available');
return fallback || key;
}
const translation = window.i18n.t(key, params);
if (translation === key && fallback) {
return fallback;
}
return translation;
}
/**
* Safe translation function that waits for i18n to be ready
* @param {string} key - Translation key