mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-25 15:15:44 -03:00
feat(i18n): Implement server-side internationalization support
- Added ServerI18nManager to handle translations and locale settings on the server. - Integrated server-side translations into templates, reducing language flashing on initial load. - Created API endpoints for setting and getting user language preferences. - Enhanced client-side i18n handling to work seamlessly with server-rendered content. - Updated various templates to utilize the new translation system. - Added mixed i18n handler to coordinate server and client translations, improving user experience. - Expanded translation files to include initialization messages for various components.
This commit is contained in:
@@ -169,8 +169,19 @@ export function formatNumber(number, options = {}) {
|
||||
* This should be called after DOM content is loaded
|
||||
*/
|
||||
export function initializePageI18n() {
|
||||
// Translate all elements with data-i18n attributes
|
||||
translateDOM();
|
||||
// 优先使用服务端传递的翻译数据,避免闪烁
|
||||
if (window.__SERVER_TRANSLATIONS__ && window.__SERVER_TRANSLATIONS__.language) {
|
||||
// 设置客户端i18n的语言为服务端传递的语言
|
||||
if (window.i18n && window.i18n.setLanguage) {
|
||||
window.i18n.setLanguage(window.__SERVER_TRANSLATIONS__.language);
|
||||
}
|
||||
|
||||
// 对于剩余的需要动态翻译的元素,仍使用客户端翻译
|
||||
translateDOM();
|
||||
} else {
|
||||
// 回退到完整的客户端翻译
|
||||
translateDOM();
|
||||
}
|
||||
|
||||
// Update search placeholder based on current page
|
||||
const currentPath = window.location.pathname;
|
||||
|
||||
Reference in New Issue
Block a user