Merge pull request #68 from ADev531/main
Some checks failed
Inkay-CI / build-inkay (push) Has been cancelled

feat: added language changer and korean
This commit is contained in:
Ash 2026-05-26 12:02:31 +10:00 committed by GitHub
commit 1c795ea15b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 129 additions and 28 deletions

View File

@ -4,41 +4,47 @@
#include "lang.h"
config_strings get_config_strings(nn::swkbd::LanguageType language) {
config_strings get_config_strings(inkay_language language) {
switch (language) {
case nn::swkbd::LanguageType::English:
case inkay_language::English:
default: return {
#include "en_US.lang"
};
case nn::swkbd::LanguageType::Spanish: return {
case inkay_language::Spanish: return {
#include "es_ES.lang"
};
case nn::swkbd::LanguageType::French: return {
case inkay_language::French: return {
#include "fr_FR.lang"
};
case nn::swkbd::LanguageType::Italian: return {
case inkay_language::Italian: return {
#include "it_IT.lang"
};
case nn::swkbd::LanguageType::German: return {
case inkay_language::German: return {
#include "de_DE.lang"
};
case nn::swkbd::LanguageType::SimplifiedChinese: return {
case inkay_language::SimplifiedChinese: return {
#include "zh_CN.lang"
};
case nn::swkbd::LanguageType::TraditionalChinese: return {
case inkay_language::TraditionalChinese: return {
#include "zh_Hant.lang"
};
case nn::swkbd::LanguageType::Portuguese: return {
case inkay_language::Portuguese: return {
#include "pt_BR.lang"
};
case nn::swkbd::LanguageType::Japanese: return {
case inkay_language::Japanese: return {
#include "ja_JP.lang"
};
case nn::swkbd::LanguageType::Dutch: return {
case inkay_language::Dutch: return {
#include "nl_NL.lang"
};
case nn::swkbd::LanguageType::Russian: return {
case inkay_language::Russian: return {
#include "ru_RU.lang"
};
case inkay_language::Korean: return {
#include "ko_KR.lang"
};
case inkay_language::EnUwU: return {
#include "en@uwu.lang"
};
}
}

View File

@ -1,7 +1,26 @@
#pragma once
#include <string_view>
#include <nn/swkbd.h>
enum inkay_language {
// Wii U System Languages
Japanese = 0,
English,
French,
German,
Italian,
Spanish,
SimplifiedChinese,
Korean,
Dutch,
Portuguese,
Russian,
TraditionalChinese,
Invalid,
// Custom Languages
System,
EnUwU,
};
struct config_strings {
const char *plugin_name;
@ -20,4 +39,4 @@ struct config_strings {
std::string_view module_init_not_found;
};
config_strings get_config_strings(nn::swkbd::LanguageType language);
config_strings get_config_strings(inkay_language language);

View File

@ -25,6 +25,7 @@
#include <wups.h>
#include <wups/storage.h>
#include <wups/config_api.h>
#include <wups/config/WUPSConfigItemMultipleValues.h>
#include <wups/config/WUPSConfigItemBoolean.h>
#include <wups/config/WUPSConfigItemStub.h>
@ -43,6 +44,8 @@ bool Config::show_startup_toast = true;
bool Config::need_relaunch = false;
bool Config::unregister_task_item_pressed = false;
bool Config::is_wiiu_menu = false;
uint32_t Config::language = 13;
inkay_language Config::current_language = English;
static WUPSConfigAPICallbackStatus report_error(WUPSConfigAPIStatus err) {
DEBUG_FUNCTION_LINE_VERBOSE("WUPS config error: %s", WUPSConfigAPI_GetStatusStr(err));
@ -65,6 +68,21 @@ static void connect_to_network_changed(ConfigItemBoolean* item, bool new_value)
if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res);
}
static void language_changed(ConfigItemMultipleValues* item, uint32_t new_value) {
DEBUG_FUNCTION_LINE_VERBOSE("language changed to: %d", new_value);
if (new_value != Config::language) {
if (new_value == inkay_language::System)
Config::current_language = (inkay_language)get_system_language();
else
Config::current_language = (inkay_language)new_value;
}
Config::language = new_value;
WUPSStorageError res;
res = WUPSStorageAPI::Store<int>("language", Config::language);
if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res);
}
static void show_startup_toast_changed(ConfigItemBoolean* item, bool new_value) {
DEBUG_FUNCTION_LINE_VERBOSE("show_startup_toast changed to: %d", new_value);
Config::show_startup_toast = new_value;
@ -134,7 +152,7 @@ static WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHa
Config::is_wiiu_menu = (current_title_id == wiiu_menu_tid);
// get translation strings
strings = get_config_strings(get_system_language());
strings = get_config_strings(Config::current_language);
// create root config category
WUPSConfigCategory root = WUPSConfigCategory(rootHandle);
@ -194,9 +212,33 @@ static WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHa
err = WUPSConfigAPI_Category_AddItem(other_cat->getHandle(), unregisterTasksItem);
if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err);
constexpr WUPSConfigItemMultipleValues::ValuePair languages[] = {
{0, "Japanese"},
{1, "English"},
{2, "French"},
{3, "German"},
{4, "Italian"},
{5, "Spanish"},
{6, "Simplified Chinese"},
{7, "Korean"},
{8, "Dutch"},
{9, "Portuguese"},
{10, "Russian"},
{11, "Traditional Chinese"},
{13, "System"},
{14, "English (UwU)"},
};
auto language_item = WUPSConfigItemMultipleValues::CreateFromValue("language", "Language", 13, Config::language, languages, &language_changed, err);
if (!language_item) return report_error(err);
res = other_cat->add(std::move(*language_item), err);
if (!res) return report_error(err);
res = other_cat->add(std::move(*startup_toast_item), err);
if (!res) return report_error(err);
res = root.add(std::move(*other_cat), err);
if (!res) return report_error(err);
@ -244,6 +286,16 @@ void Config::Init() {
}
else if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res);
res = WUPSStorageAPI::Get<uint32_t>("language", Config::language);
if (res == WUPS_STORAGE_ERROR_NOT_FOUND) {
DEBUG_FUNCTION_LINE("Language value not found, attempting to create");
// Add the value to the storage.
res = WUPSStorageAPI::Store<uint32_t>("language", Config::language);
if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res);
}
else if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res);
res = WUPSStorageAPI::Get<bool>("show_startup_toast", Config::show_startup_toast);
if (res == WUPS_STORAGE_ERROR_NOT_FOUND) {
DEBUG_FUNCTION_LINE("Show startup toast value not found, attempting to create");
@ -254,6 +306,12 @@ void Config::Init() {
}
else if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res);
// Set the language that's currently used
if (Config::language == inkay_language::System)
Config::current_language = (inkay_language)get_system_language();
else
Config::current_language = (inkay_language)Config::language;
// Save storage
res = WUPSStorageAPI::SaveStorage();
if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res);

View File

@ -5,12 +5,16 @@
#ifndef INKAY_CONFIG_H
#define INKAY_CONFIG_H
#include <stdint.h>
#include "lang.h"
class Config {
public:
static void Init();
// wups config items
static bool connect_to_network;
static uint32_t language;
static bool show_startup_toast;
@ -20,6 +24,7 @@ public:
// private stuff
static bool is_wiiu_menu;
static inkay_language current_language;
static bool unregister_task_item_pressed;
};

View File

@ -18,22 +18,22 @@
#include "Notification.h"
#include "utils/logger.h"
#include "sysconfig.h"
#include "config.h"
#include "lang.h"
#include <coreinit/dynload.h>
static OSDynLoad_Module module;
static void (*moduleInitialize)(bool, bool) = nullptr;
static void (*moduleInitialize)(bool, bool, inkay_language) = nullptr;
static InkayStatus (*moduleGetStatus)() = nullptr;
static void (*moduleSetPluginRunning)() = nullptr;
static const char *get_module_not_found_message() {
return get_config_strings(get_system_language()).module_not_found.data();
return get_config_strings(Config::current_language).module_not_found.data();
}
static const char *get_module_init_not_found_message() {
return get_config_strings(get_system_language()).module_init_not_found.data();
return get_config_strings(Config::current_language).module_init_not_found.data();
}
void Inkay_Initialize(bool apply_patches, bool show_startup_toast) {
@ -53,8 +53,8 @@ void Inkay_Initialize(bool apply_patches, bool show_startup_toast) {
OSDynLoad_Release(module);
return;
}
moduleInitialize(apply_patches, show_startup_toast);
moduleInitialize(apply_patches, show_startup_toast, Config::current_language);
}
void Inkay_Finalize() {

13
src/lang/ko_KR.lang Normal file
View File

@ -0,0 +1,13 @@
.plugin_name="Inkay"
,.network_category="네트워크 선택"
,.connect_to_network_setting="Pretendo Network 사용"
,.other_category="기타 설정"
,.reset_wwp_setting="Wara Wara Plaza 초기화"
,.press_a_action="A 버튼을 누르세요"
,.restart_to_apply_action="재시작 후 적용"
,.need_menu_action="Wii U 메뉴에서만"
,.using_nintendo_network="Nintendo Network 사용 중"
,.using_pretendo_network="Pretendo Network 사용 중"
,.multiplayer_port_display="멀티플레이어에 UDP 포트 %hu을(를) 사용합니다"
,.module_not_found="패치를 적용하는 데 실패했습니다. Aroma Updater로 복구해 주세요. (686-1001 모듈 없음)"
,.module_init_not_found="패치를 적용하는 데 실패했습니다. Aroma Updater로 복구해 주세요. (686-1002 모듈 초기화)"

View File

@ -93,18 +93,18 @@ static bool is555(MCPSystemVersion version) {
return (version.major == 5) && (version.minor == 5) && (version.patch >= 5);
}
static const char *get_nintendo_network_message() {
static const char *get_nintendo_network_message(inkay_language language) {
// TL note: "Nintendo Network" is a proper noun - "Network" is part of the name
// TL note: "Using" instead of "Connected" is deliberate - we don't know if a successful connection exists, we are
// only specifying what we'll *attempt* to connect to
return get_config_strings(get_system_language()).using_nintendo_network.data();
return get_config_strings(language).using_nintendo_network.data();
}
static const char *get_pretendo_message() {
static const char *get_pretendo_message(inkay_language language) {
// TL note: "Pretendo Network" is also a proper noun - though "Pretendo" alone can refer to us as a project
// TL note: "Using" instead of "Connected" is deliberate - we don't know if a successful connection exists, we are
// only specifying what we'll *attempt* to connect to
return get_config_strings(get_system_language()).using_pretendo_network.data();
return get_config_strings(language).using_pretendo_network.data();
}
static void Inkay_SetPluginRunning() {
@ -122,7 +122,7 @@ static InkayStatus Inkay_GetStatus() {
}
}
static void Inkay_Initialize(bool apply_patches, bool show_startup_toast) {
static void Inkay_Initialize(bool apply_patches, bool show_startup_toast, inkay_language language) {
if (Config::initialized)
return;
@ -153,14 +153,14 @@ static void Inkay_Initialize(bool apply_patches, bool show_startup_toast) {
DEBUG_FUNCTION_LINE_VERBOSE("Pretendo URL and NoSSL patches applied successfully.");
if (Config::show_startup_toast) {
ShowNotification(get_pretendo_message());
ShowNotification(get_pretendo_message(language));
}
Config::initialized = true;
} else {
DEBUG_FUNCTION_LINE_VERBOSE("Pretendo URL and NoSSL patches skipped.");
if(Config::show_startup_toast) {
ShowNotification(get_nintendo_network_message());
ShowNotification(get_nintendo_network_message(language));
}
Config::initialized = true;
return;