mirror of
https://github.com/HeyPuter/puter.git
synced 2026-01-05 12:40:26 -06:00
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.
This commit is contained in:
@@ -166,7 +166,26 @@ function UIItem(options){
|
||||
// divider
|
||||
h += `<div class="item-divider"></div>`;
|
||||
// name
|
||||
h += `<pre class="item-name" data-item-id="${item_id}" title="${html_encode(options.name)}">${options.is_trash ? i18n('trash') : html_encode(truncate_filename(options.name))}</pre>`
|
||||
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 += `<pre class="item-name" data-item-id="${item_id}" title="${html_encode(options.name)}">${display_name}</pre>`
|
||||
// name editor
|
||||
h += `<textarea class="item-name-editor hide-scrollbar" spellcheck="false" autocomplete="off" autocorrect="off" autocapitalize="off" data-gramm_editor="false">${html_encode(options.name)}</textarea>`
|
||||
h += `</div>`;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user