From 4dae0d637086189ca7050cafa5f6f2ccf79de422 Mon Sep 17 00:00:00 2001 From: Nariman Jelveh Date: Sat, 4 Oct 2025 13:04:31 -0700 Subject: [PATCH] I18n for sys dirs (#1679) * improve UIItem and UIWindow to support internationalization for system directory names. Updated UIItem to display localized names for trash, desktop, home, documents, pictures, videos, and public directories. Modified UIWindow to set the window title using localized names for the desktop and home paths. * refactor UIWindow to use i18n for system directory titles. Updated window title settings for desktop, documents, pictures, videos, public, and trash paths to use localized names, improving user experience across different languages. --- src/gui/src/UI/UIItem.js | 21 ++++++++++++++++++++- src/gui/src/UI/UIWindow.js | 22 +++++++++++++++++----- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/gui/src/UI/UIItem.js b/src/gui/src/UI/UIItem.js index 5813bb7ae..35519e450 100644 --- a/src/gui/src/UI/UIItem.js +++ b/src/gui/src/UI/UIItem.js @@ -166,7 +166,26 @@ function UIItem(options){ // divider h += `
`; // name - h += `
${options.is_trash ? i18n('trash') : html_encode(truncate_filename(options.name))}
` + let display_name = options.name; + // Use i18n for system directories + if (options.is_trash) { + display_name = i18n('trash'); + } else if (options.path === window.desktop_path) { + display_name = i18n('desktop'); + } else if (options.path === window.home_path) { + display_name = i18n('home'); + } else if (options.path === window.docs_path || options.path === window.documents_path) { + display_name = i18n('documents'); + } else if (options.path === window.pictures_path) { + display_name = i18n('pictures'); + } else if (options.path === window.videos_path) { + display_name = i18n('videos'); + } else if (options.path === window.public_path) { + display_name = i18n('public'); + } else { + display_name = html_encode(truncate_filename(options.name)); + } + h += `
${display_name}
` // name editor h += `` h += ``; diff --git a/src/gui/src/UI/UIWindow.js b/src/gui/src/UI/UIWindow.js index e7be4d406..cad431f66 100644 --- a/src/gui/src/UI/UIWindow.js +++ b/src/gui/src/UI/UIWindow.js @@ -3132,7 +3132,7 @@ window.update_window_path = async function(el_window, target_path){ // system directories with custom icons and predefined names if(target_path === window.desktop_path){ $(el_window).find('.window-head-icon').attr('src', window.icons['folder-desktop.svg']); - $(el_window).find('.window-head-title').text('Desktop') + $(el_window).find('.window-head-title').text(i18n('desktop')) }else if (target_path === window.home_path){ $(el_window).find('.window-head-icon').attr('src', window.icons['folder-home.svg']); $(el_window).find('.window-head-title').text(i18n('home')) @@ -3141,13 +3141,13 @@ window.update_window_path = async function(el_window, target_path){ $(el_window).find('.window-head-title').text(i18n('documents')) }else if (target_path === window.public_path){ $(el_window).find('.window-head-icon').attr('src', window.icons['folder-public.svg']); - $(el_window).find('.window-head-title').text(i18n('window_title_public')) + $(el_window).find('.window-head-title').text(i18n('public')) }else if (target_path === window.videos_path){ $(el_window).find('.window-head-icon').attr('src', window.icons['folder-videos.svg']); - $(el_window).find('.window-head-title').text(i18n('window_title_videos')) + $(el_window).find('.window-head-title').text(i18n('videos')) }else if (target_path === window.pictures_path){ $(el_window).find('.window-head-icon').attr('src', window.icons['folder-pictures.svg']); - $(el_window).find('.window-head-title').text(i18n('window_title_pictures')) + $(el_window).find('.window-head-title').text(i18n('pictures')) }// root folder of a shared user? else if((target_path.split('/').length - 1) === 1 && target_path !== '/'+window.user.username) $(el_window).find('.window-head-icon').attr('src', window.icons['shared.svg']); @@ -3169,9 +3169,21 @@ window.update_window_path = async function(el_window, target_path){ $(el_window).attr('data-sort_order', fsentry.sort_order ?? 'asc'); $(el_window).attr('data-layout', fsentry.layout ?? 'icons'); $(el_window_item_container).attr('data-uid', fsentry.id); - // title + // title - use i18n for system directories if (target_path === window.home_path) $(el_window).find('.window-head-title').text(i18n('home')) + else if (target_path === window.desktop_path) + $(el_window).find('.window-head-title').text(i18n('desktop')) + else if (target_path === window.docs_path || target_path === window.documents_path) + $(el_window).find('.window-head-title').text(i18n('documents')) + else if (target_path === window.pictures_path) + $(el_window).find('.window-head-title').text(i18n('pictures')) + else if (target_path === window.videos_path) + $(el_window).find('.window-head-title').text(i18n('videos')) + else if (target_path === window.public_path) + $(el_window).find('.window-head-title').text(i18n('public')) + else if (target_path === window.trash_path) + $(el_window).find('.window-head-title').text(i18n('trash')) else $(el_window).find('.window-head-title').text(fsentry.name); // data-name