mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-21 21:22:11 -03:00
feat(localization): add model description translations and enhance UI text across multiple languages
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user