From b262649ca96e8b36a6c97cf322cf4796ad0f050c Mon Sep 17 00:00:00 2001 From: shadow2560 <24191064+shadow2560@users.noreply.github.com> Date: Sun, 22 Dec 2024 16:25:25 +0100 Subject: [PATCH 1/4] Change how HBMenu replacement is done, fix a bug witch logging all homebrews as stared, update french translation to include some missing strings. Signed-off-by: shadow2560 <24191064+shadow2560@users.noreply.github.com> --- assets/romfs/i18n/de.json | 2 +- assets/romfs/i18n/en.json | 2 +- assets/romfs/i18n/es.json | 2 +- assets/romfs/i18n/fr.json | 9 ++++- assets/romfs/i18n/it.json | 2 +- assets/romfs/i18n/ja.json | 2 +- assets/romfs/i18n/ko.json | 2 +- assets/romfs/i18n/nl.json | 2 +- assets/romfs/i18n/pt.json | 2 +- assets/romfs/i18n/ru.json | 2 +- assets/romfs/i18n/se.json | 2 +- assets/romfs/i18n/zh.json | 2 +- sphaira/include/app.hpp | 2 +- sphaira/include/option.hpp | 20 ++++++++++ sphaira/source/app.cpp | 56 ++++++++++++++++++--------- sphaira/source/option.cpp | 14 +++++++ sphaira/source/ui/menus/homebrew.cpp | 2 +- sphaira/source/ui/menus/main_menu.cpp | 2 +- 18 files changed, 94 insertions(+), 33 deletions(-) diff --git a/assets/romfs/i18n/de.json b/assets/romfs/i18n/de.json index 87d5099..ef6177b 100644 --- a/assets/romfs/i18n/de.json +++ b/assets/romfs/i18n/de.json @@ -72,7 +72,7 @@ "Portuguese": "Português", "Russian": "Русский", "Logging": "Logging", - "Replace hbmenu on exit": "Ersetzen Sie hbmenu beim Beenden", + "Sphaira replace HBMenu": "", "Misc": "Sonstiges", "Misc Options": "Verschiedene Optionen", "Web": "Web", diff --git a/assets/romfs/i18n/en.json b/assets/romfs/i18n/en.json index 735c4e9..99f8a5b 100644 --- a/assets/romfs/i18n/en.json +++ b/assets/romfs/i18n/en.json @@ -72,7 +72,7 @@ "Portuguese": "Português", "Russian": "Русский", "Logging": "Logging", - "Replace hbmenu on exit": "Replace hbmenu on exit", + "Sphaira replace HBMenu": "Sphaira replace HBMenu", "Misc": "Misc", "Misc Options": "Misc Options", "Web": "Web", diff --git a/assets/romfs/i18n/es.json b/assets/romfs/i18n/es.json index 91018a6..6bc8ed9 100644 --- a/assets/romfs/i18n/es.json +++ b/assets/romfs/i18n/es.json @@ -72,7 +72,7 @@ "Portuguese": "Português", "Russian": "Русский", "Logging": "Explotación florestal", - "Replace hbmenu on exit": "Reemplazar hbmenu al salir", + "Sphaira replace HBMenu": "", "Misc": "Varios", "Misc Options": "Opciones varias", "Web": "Web", diff --git a/assets/romfs/i18n/fr.json b/assets/romfs/i18n/fr.json index 4f64248..0c2c1fc 100644 --- a/assets/romfs/i18n/fr.json +++ b/assets/romfs/i18n/fr.json @@ -25,6 +25,7 @@ "No": "Non", "Enabled": "Activé(e)", "Disabled": "Désactivé(e)", +"Unstar": "Retirer des favories", "Sort By": "Tri Par", "Sort Options": "Options de Tri", @@ -71,8 +72,9 @@ "Dutch": "Dutch", "Portuguese": "Português", "Russian": "Русский", + "Swedish": "Swedish", "Logging": "Journalisation", - "Replace hbmenu on exit": "Remplacer hbmenu quand quitté", + "Sphaira replace HBMenu": "Sphaira remplace HBMenu", "Misc": "Divers", "Misc Options": "Options Diverses", "Web": "Web", @@ -105,6 +107,11 @@ "Homebrew": "Homebrew", "Homebrew Options": "Options Homebrew", "Hide Sphaira": "Masquer Sphaira", + "Install forwarders": "Installer les Forwarders", + "Show install warning": "Afficher l'avertissement d'installation", + "Install location": "Emplacement d'installation", + "System memory": "Mémoire système", + "microSD card": "microSD card", "Install Forwarder": "Installer le Forwarder", "WARNING: Installing forwarders will lead to a ban!": "ATTENTION: L'installation de forwarders entraînera un ban!", "Installing Forwarder": "Installation Du Forwarder", diff --git a/assets/romfs/i18n/it.json b/assets/romfs/i18n/it.json index 2837f4a..9eb6e51 100644 --- a/assets/romfs/i18n/it.json +++ b/assets/romfs/i18n/it.json @@ -72,7 +72,7 @@ "Portuguese": "Português", "Russian": "Русский", "Logging": "Logging", - "Replace hbmenu on exit": "Sostituisci hbmenu all'uscita", + "Sphaira replace HBMenu": "", "Misc": "Varie", "Misc Options": "Opzioni varie", "Web": "Rete", diff --git a/assets/romfs/i18n/ja.json b/assets/romfs/i18n/ja.json index 7469939..07cd4f4 100644 --- a/assets/romfs/i18n/ja.json +++ b/assets/romfs/i18n/ja.json @@ -72,7 +72,7 @@ "Portuguese": "Português", "Russian": "Русский", "Logging": "ログの取得", - "Replace hbmenu on exit": "終了時に hbmenu を置き換える", + "Sphaira replace HBMenu": "", "Misc": "その他", "Misc Options": "その他", "Web": "ウェブブラウザ", diff --git a/assets/romfs/i18n/ko.json b/assets/romfs/i18n/ko.json index 4b22a15..b403459 100644 --- a/assets/romfs/i18n/ko.json +++ b/assets/romfs/i18n/ko.json @@ -72,7 +72,7 @@ "Portuguese": "Português", "Russian": "Русский", "Logging": "로깅", - "Replace hbmenu on exit": "hbmenu를 교체", + "Sphaira replace HBMenu": "", "Misc": "기타", "Misc Options": "기타", "Web": "웹 브라우저", diff --git a/assets/romfs/i18n/nl.json b/assets/romfs/i18n/nl.json index 3655bb3..2922975 100644 --- a/assets/romfs/i18n/nl.json +++ b/assets/romfs/i18n/nl.json @@ -72,7 +72,7 @@ "Portuguese": "Português", "Russian": "Русский", "Logging": "Loggen", - "Replace hbmenu on exit": "Vervang hbmenu bij afsluiten", + "Sphaira replace HBMenu": "", "Misc": "Diversen", "Misc Options": "Diverse opties", "Web": "Web", diff --git a/assets/romfs/i18n/pt.json b/assets/romfs/i18n/pt.json index 330a5a2..7b34e9a 100644 --- a/assets/romfs/i18n/pt.json +++ b/assets/romfs/i18n/pt.json @@ -72,7 +72,7 @@ "Portuguese": "Português", "Russian": "Русский", "Logging": "Logging", - "Replace hbmenu on exit": "Substitua hbmenu ao sair", + "Sphaira replace HBMenu": "", "Misc": "Diversos", "Misc Options": "Opções diversas", "Web": "Rede", diff --git a/assets/romfs/i18n/ru.json b/assets/romfs/i18n/ru.json index 23a589f..3fe90b8 100644 --- a/assets/romfs/i18n/ru.json +++ b/assets/romfs/i18n/ru.json @@ -72,7 +72,7 @@ "Portuguese": "Português", "Russian": "Русский", "Logging": "Журналирование", - "Replace hbmenu on exit": "Заменить hbmenu при выходе", + "Sphaira replace HBMenu": "", "Misc": "Прочее", "Misc Options": "Прочие параметры", "Web": "Интернет", diff --git a/assets/romfs/i18n/se.json b/assets/romfs/i18n/se.json index fefbe49..50b67dd 100644 --- a/assets/romfs/i18n/se.json +++ b/assets/romfs/i18n/se.json @@ -72,7 +72,7 @@ "Portuguese": "Portugisiska", "Russian": "Ryska", "Logging": "Loggning", - "Replace hbmenu on exit": "Ersätt hbmenu vid avslut", + "Sphaira replace HBMenu": "", "Misc": "Övrigt", "Misc Options": "Övriga alternativ", "Web": "Webb", diff --git a/assets/romfs/i18n/zh.json b/assets/romfs/i18n/zh.json index daa8f28..c57feb7 100644 --- a/assets/romfs/i18n/zh.json +++ b/assets/romfs/i18n/zh.json @@ -72,7 +72,7 @@ "Portuguese": "Português", "Russian": "Русский", "Logging": "日志", - "Replace hbmenu on exit": "退出后用Sphaira替换hbmenu", + "Sphaira replace HBMenu": "", "Misc": "杂项", "Misc Options": "杂项设置", "Web": "网页浏览器", diff --git a/sphaira/include/app.hpp b/sphaira/include/app.hpp index 4566021..06660a1 100644 --- a/sphaira/include/app.hpp +++ b/sphaira/include/app.hpp @@ -139,7 +139,7 @@ class App { option::OptionBool m_nxlink_enabled{INI_SECTION, "nxlink_enabled", true}; option::OptionBool m_log_enabled{INI_SECTION, "log_enabled", false}; - option::OptionBool m_replace_hbmenu{INI_SECTION, "replace_hbmenu", false}; + option::OptionNoIniBool m_replace_hbmenu{"replace_hbmenu", false}; option::OptionBool m_install{INI_SECTION, "install", false}; option::OptionBool m_install_sd{INI_SECTION, "install_sd", true}; option::OptionLong m_install_prompt{INI_SECTION, "install_prompt", true}; diff --git a/sphaira/include/option.hpp b/sphaira/include/option.hpp index cebab9a..23cc390 100644 --- a/sphaira/include/option.hpp +++ b/sphaira/include/option.hpp @@ -23,8 +23,28 @@ struct OptionBase { std::optional m_value; }; +template +struct OptionBaseNoIni { + OptionBaseNoIni(const std::string& name, T default_value) + : m_name{name} + , m_default_value{default_value} + {} + + auto Get() -> T; + void Set(T value); + +private: + const std::string m_name; + const T m_default_value; + std::optional m_value; +}; + using OptionBool = OptionBase; using OptionLong = OptionBase; using OptionString = OptionBase; +using OptionNoIniBool = OptionBaseNoIni; +using OptionNoIniLong = OptionBaseNoIni; +using OptionNoIniString = OptionBaseNoIni; + } // namespace sphaira::option diff --git a/sphaira/source/app.cpp b/sphaira/source/app.cpp index 9d5c603..f2f0934 100644 --- a/sphaira/source/app.cpp +++ b/sphaira/source/app.cpp @@ -849,8 +849,10 @@ App::App(const char* argv0) { // set if we are hbmenu if (IsHbmenu()) { __nx_applet_exit_mode = 1; + g_app->m_replace_hbmenu.Set(true); + } else { + g_app->m_replace_hbmenu.Set(false); } - fs::FsNativeSd fs; fs.CreateDirectoryRecursively("/config/sphaira/assoc"); fs.CreateDirectoryRecursively("/config/sphaira/themes"); @@ -1052,10 +1054,10 @@ App::~App() { if (App::GetReplaceHbmenuEnable() && !IsHbmenu()) { NacpStruct nacp; fs::FsNativeSd fs; - if (R_SUCCEEDED(nro_get_nacp("/hbmenu.nro", nacp)) && std::strcmp(nacp.lang[0].name, "sphaira")) { + if (R_SUCCEEDED(nro_get_nacp("/hbmenu.nro", nacp)) && std::strcmp(nacp.lang[0].name, "nx-hbmenu") == 0) { log_write("backing up hbmenu\n"); if (R_FAILED(fs.copy_entire_file("/switch/hbmenu.nro", "/hbmenu.nro", true))) { - log_write("failed to copy sphaire.nro to hbmenu.nro\n"); + log_write("failed to copy hbmenu.nro\n"); } } else { log_write("not backing up\n"); @@ -1068,25 +1070,43 @@ App::~App() { log_write("success with copying over root file!\n"); } } else if (IsHbmenu()) { - // check we have a version that's newer than current. fs::FsNativeSd fs; - NacpStruct sphaira_nacp; - fs::FsPath sphaira_path = "/switch/sphaira/sphaira.nro"; - Result rc; + if (!App::GetReplaceHbmenuEnable()) { + log_write("Restoring Sphaira\n"); + if (R_FAILED(fs.copy_entire_file("/switch/sphaira/sphaira.nro", GetExePath(), true))) { + log_write("failed to restore Sphaira\n"); + } else { + log_write("success with restoring Sphaira!\n"); + NacpStruct nacp; + if (R_SUCCEEDED(nro_get_nacp("/switch/hbmenu.nro", nacp)) && std::strcmp(nacp.lang[0].name, "nx-hbmenu") == 0) { + log_write("Restoring HBMenu\n"); + if (R_FAILED(fs.copy_entire_file("/hbmenu.nro", "/switch/hbmenu.nro", true))) { + log_write("failed to restore hbmenu.nro\n"); + } + } else { + log_write("not restoring HBMenu\n"); + } + } + } else { + // check we have a version that's newer than current. + NacpStruct sphaira_nacp; + fs::FsPath sphaira_path = "/switch/sphaira/sphaira.nro"; + Result rc; - rc = nro_get_nacp(sphaira_path, sphaira_nacp); - if (R_FAILED(rc) || std::strcmp(sphaira_nacp.lang[0].name, "sphaira")) { - sphaira_path = "/switch/sphaira.nro"; rc = nro_get_nacp(sphaira_path, sphaira_nacp); - } + if (R_FAILED(rc) || std::strcmp(sphaira_nacp.lang[0].name, "sphaira") != 0) { + sphaira_path = "/switch/sphaira.nro"; + rc = nro_get_nacp(sphaira_path, sphaira_nacp); + } - // found sphaira, now lets get compare version - if (R_SUCCEEDED(rc) && !std::strcmp(sphaira_nacp.lang[0].name, "sphaira")) { - if (std::strcmp(APP_VERSION, sphaira_nacp.display_version) < 0) { - if (R_FAILED(rc = fs.copy_entire_file(GetExePath(), sphaira_path, true))) { - log_write("failed to copy entire file: %s 0x%X module: %u desc: %u\n", sphaira_path, rc, R_MODULE(rc), R_DESCRIPTION(rc)); - } else { - log_write("success with updating hbmenu!\n"); + // found sphaira, now lets get compare version + if (R_SUCCEEDED(rc) && !std::strcmp(sphaira_nacp.lang[0].name, "sphaira") == 0) { + if (std::strcmp(APP_VERSION, sphaira_nacp.display_version) < 0) { + if (R_FAILED(rc = fs.copy_entire_file(GetExePath(), sphaira_path, true))) { + log_write("failed to copy entire file: %s 0x%X module: %u desc: %u\n", sphaira_path, rc, R_MODULE(rc), R_DESCRIPTION(rc)); + } else { + log_write("success with updating hbmenu!\n"); + } } } } diff --git a/sphaira/source/option.cpp b/sphaira/source/option.cpp index 6f7261e..96b780f 100644 --- a/sphaira/source/option.cpp +++ b/sphaira/source/option.cpp @@ -37,4 +37,18 @@ template struct OptionBase; template struct OptionBase; template struct OptionBase; +template +auto OptionBaseNoIni::Get() -> T { + return m_value.value(); +} + +template +void OptionBaseNoIni::Set(T value) { + m_value = value; +} + +template struct OptionBaseNoIni; +template struct OptionBaseNoIni; +template struct OptionBaseNoIni; + } // namespace sphaira::option diff --git a/sphaira/source/ui/menus/homebrew.cpp b/sphaira/source/ui/menus/homebrew.cpp index 0fb5e10..5c7ec7f 100644 --- a/sphaira/source/ui/menus/homebrew.cpp +++ b/sphaira/source/ui/menus/homebrew.cpp @@ -317,7 +317,7 @@ void Menu::Sort() { fs::FsPath star_path; for (auto& p : m_entries) { p.has_star = fs.FileExists(GenerateStarPath(p.path)); - if (p.has_star) { + if (p.has_star == true) { log_write("found star: %s\n", p.path.s); } else { log_write("no star: %s\n", p.path.s); diff --git a/sphaira/source/ui/menus/main_menu.cpp b/sphaira/source/ui/menus/main_menu.cpp index 6823738..f99ba57 100644 --- a/sphaira/source/ui/menus/main_menu.cpp +++ b/sphaira/source/ui/menus/main_menu.cpp @@ -312,7 +312,7 @@ MainMenu::MainMenu() { App::SetLogEnable(enable); }, "Enabled"_i18n, "Disabled"_i18n)); - options->Add(std::make_shared("Replace hbmenu on exit"_i18n, App::GetReplaceHbmenuEnable(), [this](bool& enable){ + options->Add(std::make_shared("Sphaira replace HBMenu"_i18n, App::GetReplaceHbmenuEnable(), [this](bool& enable){ App::SetReplaceHbmenuEnable(enable); }, "Enabled"_i18n, "Disabled"_i18n)); From 768cf7ef58d7e1538122d69bf6de2ef900dfbe41 Mon Sep 17 00:00:00 2001 From: shadow2560 <24191064+shadow2560@users.noreply.github.com> Date: Mon, 23 Dec 2024 09:02:50 +0100 Subject: [PATCH 2/4] Update es and zh languages. Signed-off-by: shadow2560 <24191064+shadow2560@users.noreply.github.com> --- assets/romfs/i18n/es.json | 212 +++++++++++++++++++------------------- assets/romfs/i18n/zh.json | 174 ++++++++++++++++--------------- 2 files changed, 198 insertions(+), 188 deletions(-) diff --git a/assets/romfs/i18n/es.json b/assets/romfs/i18n/es.json index 6bc8ed9..7e76b39 100644 --- a/assets/romfs/i18n/es.json +++ b/assets/romfs/i18n/es.json @@ -1,23 +1,23 @@ { - "[Applet Mode]": "[Modo subprograma]", - "No Internet": "sin internet", - "Files": "", - "Apps": "", - "Store": "", + "[Applet Mode]": "[Modo Applet]", + "No Internet": "Sin Internet", + "Files": "Archivos", + "Apps": "Apps", + "Store": "Tienda", "Menu": "Menú", "Options": "Opciones", - "OK": "", + "OK": "OK", "Back": "Atrás", - "Select": "", + "Select": "Seleccionar", "Open": "Abierto", - "Launch": "Lanzamiento", + "Launch": "Ejecutar", "Info": "Información", "Install": "Instalar", "Delete": "Borrar", - "Changelog": "", - "Details": "", - "Update": "", - "Remove": "", + "Changelog": "Log de Cambios", + "Details": "Detalles", + "Update": "Actualizar", + "Remove": "Borrar", "Download": "Descargar", "Next Page": "Página siguiente", "Prev Page": "Página anterior", @@ -36,30 +36,30 @@ "Downloads": "Descargas", "Size": "Tamaño", "Alphabetical": "Alfabético", - "Likes": "", - "ID": "", + "Likes": "Me Gusta", + "ID": "ID", "Decending": "Descendente", - "Descending (down)": "Descendente", + "Descending (down)": "Descendente (abajo)", "Desc": "Descendente", "Ascending": "Ascendente", - "Ascending (Up)": "Ascendente", + "Ascending (Up)": "Ascendente (arriba)", "Asc": "Ascendente", - "Menu Options": "Opciones de menú", + "Menu Options": "Opciones de Menú", "Header": "Encabezamiento", "Theme": "Tema", - "Theme Options": "Opciones de tema", - "Select Theme": "Seleccionar tema", + "Theme Options": "Opciones de Tema", + "Select Theme": "Seleccionar Tema", "Shuffle": "Barajar", "Music": "Música", "Network": "Red", - "Network Options": "Opciones de red", + "Network Options": "Opciones de Red", "Nxlink": "Nxlink", - "Nxlink Connected": "", - "Nxlink Upload": "", - "Nxlink Finished": "", + "Nxlink Connected": "Nxlink Conectado", + "Nxlink Upload": "Nxlink Subida", + "Nxlink Finished": "Nxlink Finalizado", "Language": "Idioma", - "Auto": "", + "Auto": "Automático", "English": "English", "Japanese": "日本語", "French": "Français", @@ -72,55 +72,55 @@ "Portuguese": "Português", "Russian": "Русский", "Logging": "Explotación florestal", - "Sphaira replace HBMenu": "", + "Sphaira replace HBMenu": "Sphaira Reemplaza HBMenu", "Misc": "Varios", "Misc Options": "Opciones varias", "Web": "Web", - "FileBrowser": "Explorador de archivos", + "FileBrowser": "Explorador de Archivos", "%zd files": "%zd files", "%zd dirs": "%zd dirs", - "File Options": "Opciones de tema", - "Show Hidden": "Mostrar oculto", + "File Options": "Opciones de Tema", + "Show Hidden": "Mostrar Oculto", "Folders First": "Carpetas primero", "Hidden Last": "Oculto último", - "Cut": "Cortar", + "Cut": "Cortar ", "Copy": "Copiar", - "Paste": "", - "Paste ": "", - " file(s)?": "", - "Rename": "Rebautizar", - "Set New File Name": "", + "Paste": "Pegar", + "Paste ": "Pegar ", + " file(s)?": " ¿archivo(s)?", + "Rename": "Renombrar", + "Set New File Name": "Establecer Nuevo Nombre de Archivo", "Advanced": "Avanzado", - "Advanced Options": "Crear archivo", + "Advanced Options": "Opciones Avanzadas", "Create File": "Crear archivo", - "Set File Name": "", + "Set File Name": "Establecer Nombre de Archivo", "Create Folder": "Crear carpeta", - "Set Folder Name": "", + "Set Folder Name": "Establecer Nombre de Carpeta", "View as text (unfinished)": "Ver como texto (sin terminar)", - "Empty...": "", - "Open with DayBreak?": "", - "Launch option for: ": "", + "Empty...": "Vacío...", + "Open with DayBreak?": "Abrir con DayBreak", + "Launch option for: ": "Opción de ejecución para: ", - "Homebrew": "cerveza casera", - "Homebrew Options": "Opciones de elaboración casera", + "Homebrew": "Honebrew", + "Homebrew Options": "Opciones de Homebrew", "Hide Sphaira": "Ocultar Sphaira", - "Install Forwarder": "Instalar reenviador", - "WARNING: Installing forwarders will lead to a ban!": "ADVERTENCIA: ¡La instalación de reenviadores dará lugar a una prohibición!", - "Installing Forwarder": "", - "Creating Program": "", - "Creating Control": "", - "Creating Meta": "", - "Writing Nca": "", - "Updating ncm databse": "", + "Install Forwarder": "Instalar Forwarder", + "WARNING: Installing forwarders will lead to a ban!": "ADVERTENCIA: ¡La instalación de fordwarders podría producir un baneo de la consola!", + "Installing Forwarder": "Instalando Forwarder", + "Creating Program": "Creando Program", + "Creating Control": "Creando Control", + "Creating Meta": "Creando Meta", + "Writing Nca": "Creando NCA", + "Updating ncm databse": "Actualizando base de datos ncm ", "Pushing application record": "", - "Installed!": "", - "Failed to install forwarder": "", + "Installed!": "¡Instalado!", + "Failed to install forwarder": "Fallo al instalar forwarder", - "AppStore": "", + "AppStore": "AppStore", "Filter: %s | Sort: %s | Order: %s": "Filtrar: %s | Clasificar: %s | Orden: %s", - "AppStore Options": "Opciones de la tienda de aplicaciones", + "AppStore Options": "Opciones de la AppStore", "All": "Todo", "Games": "Juegos", "Emulators": "Emuladores", @@ -132,77 +132,77 @@ "category: %s": "category: %s", "extracted: %.2f MiB": "extracted: %.2f MiB", "app_dls: %s": "app_dls: %s", - "More by Author": "", - "Leave Feedback": "", + "More by Author": "Mostrar mas del Autor", + "Leave Feedback": "Dejar Mensaje", - "Irs": "irs", - "Ambient Noise Level: ": "", - "Controller": "Controlador", + "Irs": "IRS", + "Ambient Noise Level: ": "Nivel de Ruido", + "Controller": "Control", "Pad ": "Almohadilla ", " (Available)": " (Disponible)", " (Unconnected)": " (Desconectado)", "HandHeld": "Portátil", "Rotation": "Rotación", - "0 (Sideways)": "0 (de lado)", - "90 (Flat)": "90 (plano)", - "180 (-Sideways)": "180 (-de lado)", - "270 (Upside down)": "270 (al revés)", + "0 (Sideways)": "0 (De Lado)", + "90 (Flat)": "90 (Plano)", + "180 (-Sideways)": "180 (-De Lado)", + "270 (Upside down)": "270 (Al Revés)", "Colour": "Color", "Grey": "Gris", - "Ironbow": "arco de hierro", + "Ironbow": "Paleta Térmica", "Green": "Verde", "Red": "Rojo", "Blue": "Azul", - "Light Target": "Objetivo de luz", - "All leds": "todos los leds", - "Bright group": "grupo brillante", - "Dim group": "grupo tenue", + "Light Target": "Objetivo de Luz", + "All leds": "Todos los leds", + "Bright group": "Grupo brillante", + "Dim group": "Grupo tenue", "None": "Ninguno", - "Gain": "Ganar", - "Negative Image": "Imagen negativa", - "Normal image": "imagen normal", - "Negative image": "Imagen negativa", + "Gain": "Ganancia", + "Negative Image": "Imagen Negativa", + "Normal image": "Imagen Normal", + "Negative image": "Imagen Negativa", "Format": "Formato", "320x240": "320×240", "160x120": "160×120", "80x60": "80×60", "40x30": "40×30", "20x15": "20×15", - "Trimming Format": "Formato de recorte", - "External Light Filter": "Filtro de luz externo", - "Load Default": "Cargar predeterminado", + "Trimming Format": "Formato de Recorte", + "External Light Filter": "Filtro de Luz Externa", + "Load Default": "Cargar Predeterminado", - "Themezer": "Temazer", - "Themezer Options": "", - "Nsfw": "", - "Page": "", + "Themezer": "Themezer", + "Themezer Options": "Opciones de Themezer", + "Nsfw": "NSFW", + "Page": "Página", "Page %zu / %zu": "Page %zu / %zu", - "Enter Page Number": "", - "Bad Page": "", - "Download theme?": "", + "Enter Page Number": "Ingresar Número de Página", + "Bad Page": "Página Errónea", + "Download theme?": "¿Descargar Tema?", - "Installing ": "", - "Uninstalling ": "", - "Deleting ": "", - "Deleting": "", - "Pasting ": "", - "Pasting": "", - "Removing ": "", - "Scanning ": "", - "Creating ": "", - "Copying ": "", - "Downloading ": "", - "Checking MD5": "", - "Loading...": "", - "Loading": "", - "Empty!": "", - "Not Ready...": "", - "Error loading page!": "", - "Update avaliable: ": "", - "Download update: ": "", - "Failed to download update": "", - "Delete Selected files?": "", - "Completely remove ": "", - "Are you sure you want to delete ": "¿Estás seguro de que quieres eliminar? ", - "Are you sure you wish to cancel?": "" + "Installing ": "Instalando ", + "Uninstalling ": "Desinstalando ", + "Deleting ": "Borrando ", + "Deleting": "Borrando", + "Pasting ": "Pegando ", + "Pasting": "Pegando", + "Removing ": "Removiendo ", + "Scanning ": "Escaneando ", + "Creating ": "Creando ", + "Copying ": "Copiando ", + "Downloading ": "Descargando ", + "Checking MD5": "Chqueando MD5", + "Loading...": "Cargando...", + "Loading": "Cargando", + "Empty!": "¡Vacío!", + "Not Ready...": "No Listo Aún...", + "Error loading page!": "¡Error cargando la página!", + "Update avaliable: ": "Actualización disponible: ", + "Download update: ": "Descargar actualización: ", + "Failed to download update": "Fallo al descargar actualización", + "Delete Selected files?": "¿Eliminar archivos Seleccionados?", + "Completely remove ": "Eliminar completamente", + "Are you sure you want to delete ": "¿Estás seguro que quieres eliminar? ", + "Are you sure you wish to cancel?": "¿Estás seguro que deseas cancelar?" } diff --git a/assets/romfs/i18n/zh.json b/assets/romfs/i18n/zh.json index c57feb7..47f02be 100644 --- a/assets/romfs/i18n/zh.json +++ b/assets/romfs/i18n/zh.json @@ -1,23 +1,23 @@ { "[Applet Mode]": "[小程序模式]", "No Internet": "网络未连接", - "Files": "", - "Apps": "", - "Store": "", + "Files": "文件", + "Apps": "应用", + "Store": "商店", "Menu": "菜单", "Options": "选项", - "OK": "", + "OK": "确定", "Back": "返回", - "Select": "", + "Select": "选择", "Open": "打开", "Launch": "启动", "Info": "信息", "Install": "安装", "Delete": "删除", - "Changelog": "", - "Details": "", - "Update": "", - "Remove": "", + "Changelog": "更新日志", + "Details": "详情", + "Update": "更新", + "Remove": "删除", "Download": "下载", "Next Page": "下一页", "Prev Page": "上一页", @@ -34,10 +34,10 @@ "Search": "搜索", "Updated": "最近使用", "Downloads": "下载", - "Size": "大小", + "Size": "按大小", "Alphabetical": "按字母顺序", - "Likes": "", - "ID": "", + "Likes": "点赞量", + "ID": "ID", "Decending": "降序", "Descending (down)": "降序", "Desc": "降序", @@ -55,11 +55,11 @@ "Network": "网络", "Network Options": "网络选项", "Nxlink": "Nxlink", - "Nxlink Connected": "", - "Nxlink Upload": "", - "Nxlink Finished": "", + "Nxlink Connected": "Nxlink 已连接", + "Nxlink Upload": "Nxlink 上传中", + "Nxlink Finished": "Nxlink 已结束", "Language": "语言", - "Auto": "", + "Auto": "自动", "English": "English", "Japanese": "日本語", "French": "Français", @@ -78,70 +78,70 @@ "Web": "网页浏览器", "FileBrowser": "文件浏览", - "%zd files": "%zd files", - "%zd dirs": "%zd dirs", + "%zd files": "%zd 个文件", + "%zd dirs": "%zd 个文件夹", "File Options": "文件选项", "Show Hidden": "显示隐藏项目", "Folders First": "文件夹靠前", "Hidden Last": "隐藏项目置后", "Cut": "剪切", "Copy": "复制", - "Paste": "", - "Paste ": "", - " file(s)?": "", + "Paste": "粘贴", + "Paste ": "粘贴 ", + " file(s)?": "个文件(夹)?", "Rename": "重命名", - "Set New File Name": "", + "Set New File Name": "输入新命名", "Advanced": "高级", "Advanced Options": "高级选项", "Create File": "新建文件", - "Set File Name": "", + "Set File Name": "输入文件名", "Create Folder": "新建文件夹", - "Set Folder Name": "", + "Set Folder Name": "输入文件夹名", "View as text (unfinished)": "以文本形式查看(未完善)", - "Empty...": "", - "Open with DayBreak?": "", - "Launch option for: ": "", - - "Homebrew": "插件列表", - "Homebrew Options": "插件选项", - "Hide Sphaira": "在插件列表中隐藏Sphaira", + "Empty...": "空...", + "Open with DayBreak?": "使用DayBreak打开?", + "Launch option for: ": "启动选项:", + + "Homebrew": "应用列表", + "Homebrew Options": "应用选项", + "Hide Sphaira": "在应用列表中隐藏Sphaira", "Install Forwarder": "安装前端应用", "WARNING: Installing forwarders will lead to a ban!": "警告:安装前端应用可能导致ban机!", - "Installing Forwarder": "", - "Creating Program": "", - "Creating Control": "", - "Creating Meta": "", - "Writing Nca": "", - "Updating ncm databse": "", - "Pushing application record": "", - "Installed!": "", - "Failed to install forwarder": "", + "Installing Forwarder": "正在生成前端应用", + "Creating Program": "正在创建程序", + "Creating Control": "正在创建控制器", + "Creating Meta": "正在创建元数据", + "Writing Nca": "正在写入Nca", + "Updating ncm databse": "正在更新ncm数据库", + "Pushing application record": "正在推送应用记录", + "Installed!": "安装完成!", + "Failed to install forwarder": "前端应用安装失败", - "AppStore": "插件商店", + "AppStore": "应用商店", "Filter: %s | Sort: %s | Order: %s": "筛选: %s | 排序: %s | 顺序: %s", - "AppStore Options": "插件商店选项", + "AppStore Options": "应用商店选项", "All": "全部", "Games": "游戏", "Emulators": "模拟器", "Tools": "工具", "Themes": "主题", "Legacy": "可更新", - "version: %s": "version: %s", - "updated: %s": "updated: %s", - "category: %s": "category: %s", - "extracted: %.2f MiB": "extracted: %.2f MiB", - "app_dls: %s": "app_dls: %s", - "More by Author": "", - "Leave Feedback": "", + "version: %s": "版本: %s", + "updated: %s": "更新时间: %s", + "category: %s": "分类: %s", + "extracted: %.2f MiB": "应用大小: %.2f MiB", + "app_dls: %s": "下载量: %s", + "More by Author": "作者更多作品", + "Leave Feedback": "留言反馈", "Irs": "红外成像", - "Ambient Noise Level: ": "", + "Ambient Noise Level: ": "环境噪声等级:", "Controller": "控制器", "Pad ": "手柄 ", " (Available)": " (可用的)", " (Unconnected)": " (未连接)", - "HandHeld": "", - "Rotation": "", + "HandHeld": "掌机模式", + "Rotation": "旋转", "0 (Sideways)": "0度", "90 (Flat)": "90度", "180 (-Sideways)": "180度", @@ -172,36 +172,46 @@ "Load Default": "加载默认值", "Themezer": "在线主题", - "Themezer Options": "", - "Nsfw": "", - "Page": "", - "Page %zu / %zu": "Page %zu / %zu", - "Enter Page Number": "", - "Bad Page": "", - "Download theme?": "", + "Themezer Options": "在线主题选项", + "Nsfw": "公共场合不宜的主题", + "Page": "页面", + "Page %zu / %zu": "页面 %zu / %zu", + "Enter Page Number": "输入跳转的页码", + "Bad Page": "错误的页面", + "Download theme?": "下载该主题?", - "Installing ": "", - "Uninstalling ": "", - "Deleting ": "", - "Deleting": "", - "Pasting ": "", - "Pasting": "", - "Removing ": "", - "Scanning ": "", - "Creating ": "", - "Copying ": "", - "Downloading ": "", - "Checking MD5": "", - "Loading...": "", - "Loading": "", - "Empty!": "", - "Not Ready...": "", - "Error loading page!": "", - "Update avaliable: ": "", - "Download update: ": "", - "Failed to download update": "", - "Delete Selected files?": "", - "Completely remove ": "", + "Installing ": "正在安装 ", + "Uninstalling ": "正在卸载 ", + "Deleting ": "正在删除 ", + "Deleting": "正在删除", + "Pasting ": "正在粘贴 ", + "Pasting": "正在粘贴", + "Removing ": "正在移除 ", + "Scanning ": "正在扫描 ", + "Creating ": "正在创建 ", + "Copying ": "正在复制 ", + "Downloading ": "正在下载 ", + "Checking MD5": "正在校验 MD5", + "Loading...": "加载中...", + "Loading": "加载中", + "Empty!": "空!", + "Not Ready...": "尚未准备好...", + "Error loading page!": "页面加载失败!", + "Update avaliable: ": "有可用更新!", + "Download update: ": "下载更新:", + "Failed to download update": "更新下载失败", + "Delete Selected files?": "删除选中的文件?", + "Completely remove ": "彻底删除 ", "Are you sure you want to delete ": "您确定要删除吗 ", - "Are you sure you wish to cancel?": "" + "Are you sure you wish to cancel?": "您确定要取消吗?", + "Install forwarders": "允许安装前端应用", + "Install location": "安装位置", + "Show install warning": "显示安装警告", + "System memory": "主机内存", + "microSD card": "SD卡", + "Updated (Star)": "最近更新(星标优先)", + "Alphabetical (Star)": "按字母顺序(星标优先)", + "Size (Star)": "按大小(星标优先)", + "Star": "星标", + "Unstar": "取消星标" } From 28dc2f8c9ff56d67052878fd8aa8b39366de6fe3 Mon Sep 17 00:00:00 2001 From: shadow2560 <24191064+shadow2560@users.noreply.github.com> Date: Mon, 23 Dec 2024 12:45:26 +0100 Subject: [PATCH 3/4] Force Sphaira to be launched from /switch/sphaira/sphaira.nro or from /hbmenu.nro, if not it copy the version launched to /switch/sphaira/sphaira.nro then delete the launched nro and finaly launch the copied file. This is needed for the app update process witch copy the file downloaded with the path in the zip witch is for now /switch/sphaira/sphaira.nro and not the path of the app launched and this will simplify some possible functions added in the futur. Signed-off-by: shadow2560 <24191064+shadow2560@users.noreply.github.com> --- sphaira/include/app.hpp | 1 + sphaira/source/app.cpp | 33 +++++++++++++++++++++------ sphaira/source/ui/menus/main_menu.cpp | 1 + 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/sphaira/include/app.hpp b/sphaira/include/app.hpp index 06660a1..0e0cf95 100644 --- a/sphaira/include/app.hpp +++ b/sphaira/include/app.hpp @@ -43,6 +43,7 @@ class App { static void Exit(); static void ExitRestart(); +static void VerifyLaunch(); static auto GetVg() -> NVGcontext*; static void Push(std::shared_ptr); diff --git a/sphaira/source/app.cpp b/sphaira/source/app.cpp index f2f0934..92330bb 100644 --- a/sphaira/source/app.cpp +++ b/sphaira/source/app.cpp @@ -510,6 +510,30 @@ void App::ExitRestart() { Exit(); } +void App::VerifyLaunch() { + log_write("Verifying launch path...\n"); + log_write("Launched from: %s\n", GetExePath().s); + fs::FsNativeSd fs; + fs::FsPath sphaira_path = "/switch/sphaira/sphaira.nro"; + if (std::strcmp(GetExePath().s, "/hbmenu.nro") != 0 && std::strcmp(GetExePath().s, sphaira_path.s) != 0) { + log_write("Sphaira not launched from correct path, trying to fix...\n"); + if (R_FAILED(fs.copy_entire_file(sphaira_path, GetExePath(), true))) { + log_write("Failed to copy sphaira to the correct path.\n"); + } else { + log_write("Sphaira copied, deleting actual and rebooting new...\n"); + if (R_FAILED(fs.DeleteFile(GetExePath(), true))) { + log_write("Failed to delete actual.\n"); + } else { + log_write("Delete actual success.\n"); + nro_launch(sphaira_path); + Exit(); + } + } + } else { + log_write("Sphaira launched from correct path.\n"); + } +} + void App::Poll() { m_controller.Reset(); @@ -1001,6 +1025,7 @@ App::App(const char* argv0) { } App::Push(std::make_shared()); + log_write("finished app constructor\n"); } @@ -1093,14 +1118,8 @@ App::~App() { fs::FsPath sphaira_path = "/switch/sphaira/sphaira.nro"; Result rc; - rc = nro_get_nacp(sphaira_path, sphaira_nacp); - if (R_FAILED(rc) || std::strcmp(sphaira_nacp.lang[0].name, "sphaira") != 0) { - sphaira_path = "/switch/sphaira.nro"; - rc = nro_get_nacp(sphaira_path, sphaira_nacp); - } - // found sphaira, now lets get compare version - if (R_SUCCEEDED(rc) && !std::strcmp(sphaira_nacp.lang[0].name, "sphaira") == 0) { + if (R_SUCCEEDED(rc = nro_get_nacp(sphaira_path, sphaira_nacp)) && !std::strcmp(sphaira_nacp.lang[0].name, "sphaira") == 0) { if (std::strcmp(APP_VERSION, sphaira_nacp.display_version) < 0) { if (R_FAILED(rc = fs.copy_entire_file(GetExePath(), sphaira_path, true))) { log_write("failed to copy entire file: %s 0x%X module: %u desc: %u\n", sphaira_path, rc, R_MODULE(rc), R_DESCRIPTION(rc)); diff --git a/sphaira/source/ui/menus/main_menu.cpp b/sphaira/source/ui/menus/main_menu.cpp index f99ba57..060d126 100644 --- a/sphaira/source/ui/menus/main_menu.cpp +++ b/sphaira/source/ui/menus/main_menu.cpp @@ -142,6 +142,7 @@ auto InstallUpdate(ProgressBox* pbox, const std::string url, const std::string v } // namespace MainMenu::MainMenu() { + App::VerifyLaunch(); DownloadMemoryAsync("https://api.github.com/repos/ITotalJustice/sphaira/releases/latest", "", [this](std::vector& data, bool success){ m_update_state = UpdateState::Error; ON_SCOPE_EXIT( log_write("update status: %u\n", (u8)m_update_state) ); From 5db80dd41b0bf469d06321d240bfa0c6b69da9c3 Mon Sep 17 00:00:00 2001 From: shadow2560 <24191064+shadow2560@users.noreply.github.com> Date: Mon, 23 Dec 2024 15:11:33 +0100 Subject: [PATCH 4/4] Forcing file sphaira.nro contained in zip to be copied in /switch/sphaira/sphaira.nro during update, prevent possible problems if a zip update is differently formed. Signed-off-by: shadow2560 <24191064+shadow2560@users.noreply.github.com> --- sphaira/source/ui/menus/main_menu.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sphaira/source/ui/menus/main_menu.cpp b/sphaira/source/ui/menus/main_menu.cpp index 060d126..5c21a7d 100644 --- a/sphaira/source/ui/menus/main_menu.cpp +++ b/sphaira/source/ui/menus/main_menu.cpp @@ -90,6 +90,14 @@ auto InstallUpdate(ProgressBox* pbox, const std::string url, const std::string v } Result rc; + if (strcmp(file_path.s, "/switch/sphaira/sphaira.nro") != 0 && strcmp(strrchr(file_path.s, '/'), "/sphaira.nro") == 0) { + if (R_FAILED(rc = fs.CreateDirectoryRecursively("/switch/sphaira")) && rc != FsError_ResultPathAlreadyExists) { + log_write("failed to create folder: %s 0x%04X\n", file_path, rc); + return false; + } + file_path = "/switch/sphaira/sphaira.nro"; + } + if (file_path[strlen(file_path) -1] == '/') { if (R_FAILED(rc = fs.CreateDirectoryRecursively(file_path)) && rc != FsError_ResultPathAlreadyExists) { log_write("failed to create folder: %s 0x%04X\n", file_path, rc);