mirror of
https://github.com/PretendoNetwork/Inkay.git
synced 2026-04-07 09:44:52 -05:00
feat(i18n): Improve menu text and add Spanish translation (thanks @EmiSocks)
This feels like a not very scalable way of doing translations
This commit is contained in:
parent
24596b1bff
commit
216942cb64
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "wut_extra.h"
|
||||
#include "utils/logger.h"
|
||||
#include "utils/sysconfig.h"
|
||||
#include <wups.h>
|
||||
#include <wups/storage.h>
|
||||
#include <wups/config.h>
|
||||
|
|
@ -77,14 +78,6 @@ static void connect_to_network_changed(ConfigItemBoolean* item, bool new_value)
|
|||
WUPS_StoreInt(nullptr, "connect_to_network", Config::connect_to_network);
|
||||
}
|
||||
|
||||
static int32_t unregister_task_item_get_display_value(void *context, char *out_buf, int32_t out_size) {
|
||||
if(!Config::is_wiiu_menu)
|
||||
strncpy(out_buf, "From WiiU menu only", out_size);
|
||||
else
|
||||
strncpy(out_buf, Config::unregister_task_item_pressed ? "Restart to apply" : "Press A", out_size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void unregister_task_item_pressed_cb(void *context, WUPSConfigButtons button) {
|
||||
if (!Config::unregister_task_item_pressed && Config::is_wiiu_menu && button == WUPS_CONFIG_BUTTON_A) {
|
||||
|
||||
|
|
@ -121,6 +114,54 @@ static bool unregister_task_item_is_movement_allowed(void *context) {
|
|||
return true;
|
||||
}
|
||||
|
||||
struct config_strings {
|
||||
const char* plugin_name;
|
||||
const char* network_category;
|
||||
const char* connect_to_network_setting;
|
||||
const char* other_category;
|
||||
const char* reset_wwp_setting;
|
||||
const char* press_a_action;
|
||||
const char* restart_to_apply_action;
|
||||
const char* need_menu_action;
|
||||
};
|
||||
config_strings strings;
|
||||
|
||||
constexpr config_strings get_config_strings(nn::swkbd::LanguageType language) {
|
||||
switch (language) {
|
||||
case nn::swkbd::LanguageType::English:
|
||||
default:
|
||||
return {
|
||||
.plugin_name = "Inkay",
|
||||
.network_category = "Network selection",
|
||||
.connect_to_network_setting = "Connect to the Pretendo network",
|
||||
.other_category = "Other settings",
|
||||
.reset_wwp_setting = "Reset Wara Wara Plaza",
|
||||
.press_a_action = "Press A",
|
||||
.restart_to_apply_action = "Restart to apply",
|
||||
.need_menu_action = "From WiiU menu only"
|
||||
};
|
||||
case nn::swkbd::LanguageType::Spanish:
|
||||
return {
|
||||
.plugin_name = "Inkay",
|
||||
.network_category = "Selección de red",
|
||||
.connect_to_network_setting = "Conectar a la red Pretendo",
|
||||
.other_category = "Otros ajustes",
|
||||
.reset_wwp_setting = "Restablecer Wara Wara Plaza",
|
||||
.press_a_action = "Pulsa A",
|
||||
.restart_to_apply_action = "Reinicia para confirmar",
|
||||
.need_menu_action = "Sólo desde el menú de WiiU",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t unregister_task_item_get_display_value(void *context, char *out_buf, int32_t out_size) {
|
||||
if(!Config::is_wiiu_menu)
|
||||
strncpy(out_buf, strings.need_menu_action, out_size);
|
||||
else
|
||||
strncpy(out_buf, Config::unregister_task_item_pressed ? strings.restart_to_apply_action : strings.press_a_action, out_size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
WUPS_GET_CONFIG() {
|
||||
// We open the storage so we can persist the configuration the user did.
|
||||
if (WUPS_OpenStorage() != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||
|
|
@ -128,16 +169,18 @@ WUPS_GET_CONFIG() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
strings = get_config_strings(get_system_language());
|
||||
|
||||
WUPSConfigHandle config;
|
||||
WUPSConfig_CreateHandled(&config, "Inkay");
|
||||
WUPSConfig_CreateHandled(&config, strings.plugin_name);
|
||||
|
||||
WUPSConfigCategoryHandle patching_cat;
|
||||
WUPSConfig_AddCategoryByNameHandled(config, "Patching", &patching_cat);
|
||||
WUPSConfig_AddCategoryByNameHandled(config, strings.network_category, &patching_cat);
|
||||
|
||||
WUPSConfigItemBoolean_AddToCategoryHandled(config, patching_cat, "connect_to_network", "Connect to the Pretendo network", Config::connect_to_network, &connect_to_network_changed);
|
||||
WUPSConfigItemBoolean_AddToCategoryHandled(config, patching_cat, "connect_to_network", strings.connect_to_network_setting, Config::connect_to_network, &connect_to_network_changed);
|
||||
|
||||
WUPSConfigCategoryHandle boss_cat;
|
||||
WUPSConfig_AddCategoryByNameHandled(config, "BOSS settings", &boss_cat);
|
||||
WUPSConfig_AddCategoryByNameHandled(config, strings.other_category, &boss_cat);
|
||||
|
||||
WUPSConfigCallbacks_t unregisterTasksItemCallbacks = {
|
||||
.getCurrentValueDisplay = unregister_task_item_get_display_value,
|
||||
|
|
@ -151,7 +194,7 @@ WUPS_GET_CONFIG() {
|
|||
};
|
||||
|
||||
WUPSConfigItemHandle unregisterTasksItem;
|
||||
WUPSConfigItem_Create(&unregisterTasksItem, "unregister_task_item", "Unregister Wara Wara Plaza BOSS tasks", unregisterTasksItemCallbacks, &Config::unregister_task_item_pressed);
|
||||
WUPSConfigItem_Create(&unregisterTasksItem, "unregister_task_item", strings.reset_wwp_setting, unregisterTasksItemCallbacks, &Config::unregister_task_item_pressed);
|
||||
WUPSConfigCategory_AddItem(boss_cat, unregisterTasksItem);
|
||||
|
||||
return config;
|
||||
|
|
|
|||
26
src/main.cpp
26
src/main.cpp
|
|
@ -66,6 +66,7 @@ WUPS_USE_WUT_DEVOPTAB();
|
|||
#include <mocha/mocha.h>
|
||||
#include <function_patcher/function_patching.h>
|
||||
#include "patches/account_settings.h"
|
||||
#include "utils/sysconfig.h"
|
||||
|
||||
//thanks @Gary#4139 :p
|
||||
static void write_string(uint32_t addr, const char* str)
|
||||
|
|
@ -94,6 +95,27 @@ static bool is555(MCPSystemVersion version) {
|
|||
return (version.major == 5) && (version.minor == 5) && (version.patch >= 5);
|
||||
}
|
||||
|
||||
static const char * get_nintendo_network_message() {
|
||||
// TL note: "Nintendo Network" is a proper noun - "Network" is part of the name
|
||||
switch (get_system_language()) {
|
||||
case nn::swkbd::LanguageType::English:
|
||||
default:
|
||||
return "Using Nintendo Network";
|
||||
case nn::swkbd::LanguageType::Spanish:
|
||||
return "Usando Nintendo Network";
|
||||
}
|
||||
}
|
||||
static const char * get_pretendo_message() {
|
||||
// TL note: "Pretendo" is the name - "network" is NOT part of it and can be translated
|
||||
switch (get_system_language()) {
|
||||
case nn::swkbd::LanguageType::English:
|
||||
default:
|
||||
return "Using Pretendo Network";
|
||||
case nn::swkbd::LanguageType::Spanish:
|
||||
return "Usando la red Pretendo";
|
||||
}
|
||||
}
|
||||
|
||||
INITIALIZE_PLUGIN() {
|
||||
WHBLogUdpInit();
|
||||
WHBLogCafeInit();
|
||||
|
|
@ -137,11 +159,11 @@ INITIALIZE_PLUGIN() {
|
|||
write_string(patch.address, patch.url);
|
||||
}
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Pretendo URL and NoSSL patches applied successfully.");
|
||||
StartNotificationThread("Using Pretendo Network");
|
||||
StartNotificationThread(get_pretendo_message());
|
||||
}
|
||||
else {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Pretendo URL and NoSSL patches skipped.");
|
||||
StartNotificationThread("Using Nintendo Network");
|
||||
StartNotificationThread(get_nintendo_network_message());
|
||||
}
|
||||
|
||||
MCP_Close(mcp);
|
||||
|
|
|
|||
57
src/utils/sysconfig.cpp
Normal file
57
src/utils/sysconfig.cpp
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/* Copyright 2024 Pretendo Network contributors <pretendo.network>
|
||||
Copyright 2024 Ash Logan <ash@heyquark.com>
|
||||
Copyright 2020-2022 V10lator <v10lator@myway.de>
|
||||
Copyright 2022 Xpl0itU <DaThinkingChair@protonmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "sysconfig.h"
|
||||
#include "utils/logger.h"
|
||||
|
||||
#include <coreinit/userconfig.h>
|
||||
#include <optional>
|
||||
|
||||
nn::swkbd::LanguageType get_system_language() {
|
||||
static std::optional<nn::swkbd::LanguageType> cached_language{};
|
||||
if (cached_language) return *cached_language;
|
||||
|
||||
UCHandle handle = UCOpen();
|
||||
if (handle >= 0) {
|
||||
nn::swkbd::LanguageType language;
|
||||
|
||||
UCSysConfig settings __attribute__((__aligned__(0x40))) = {
|
||||
.name = "cafe.language",
|
||||
.access = 0,
|
||||
.dataType = UC_DATATYPE_UNSIGNED_INT,
|
||||
.error = UC_ERROR_OK,
|
||||
.dataSize = sizeof(language),
|
||||
.data = &language,
|
||||
};
|
||||
|
||||
UCError err = UCReadSysConfig(handle, 1, &settings);
|
||||
UCClose(handle);
|
||||
if (err != UC_ERROR_OK) {
|
||||
DEBUG_FUNCTION_LINE("Error reading UC: %d!", err);
|
||||
return nn::swkbd::LanguageType::English;
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("System language found: %d", language);
|
||||
cached_language = language;
|
||||
return language;
|
||||
}
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("Error opening UC: %d", handle);
|
||||
return nn::swkbd::LanguageType::English;
|
||||
}
|
||||
}
|
||||
12
src/utils/sysconfig.h
Normal file
12
src/utils/sysconfig.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
//
|
||||
// Created by ash on 9/04/24.
|
||||
//
|
||||
|
||||
#ifndef INKAY_SYSCONFIG_H
|
||||
#define INKAY_SYSCONFIG_H
|
||||
|
||||
#include <nn/swkbd.h>
|
||||
|
||||
nn::swkbd::LanguageType get_system_language();
|
||||
|
||||
#endif //INKAY_SYSCONFIG_H
|
||||
Loading…
Reference in New Issue
Block a user