Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions common/lang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 "[email protected]"
};
}
}
22 changes: 20 additions & 2 deletions common/lang.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
#pragma once

#include <string_view>
#include <nn/swkbd.h>

enum inkay_language {
Japanese = 0,
English,
French,
German,
Italian,
Spanish,
SimplifiedChinese,
Korean,
Dutch,
Portuguese,
Russian,
TraditionalChinese,
Invalid,
// custom ones
System,
EnUwU,
};

struct config_strings {
const char *plugin_name;
Expand All @@ -19,4 +37,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);
59 changes: 58 additions & 1 deletion plugin/src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand All @@ -42,6 +43,8 @@ bool Config::connect_to_network = 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));
Expand All @@ -64,6 +67,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 unregister_task_item_on_input_cb(void *context, WUPSConfigSimplePadData input) {
if (!Config::unregister_task_item_pressed && Config::is_wiiu_menu && ((input.buttons_d & WUPS_CONFIG_BUTTON_A) == WUPS_CONFIG_BUTTON_A)) {

Expand Down Expand Up @@ -124,7 +142,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);
Expand Down Expand Up @@ -181,6 +199,29 @@ 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, "Spanish"},
{5, "Italian"},
{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) report_error(err);

res = root.add(std::move(*other_cat), err);
if (!res) return report_error(err);

Expand Down Expand Up @@ -228,6 +269,22 @@ 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);

// 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);
Expand Down
5 changes: 5 additions & 0 deletions plugin/src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,24 @@
#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;

// private stuff
static bool need_relaunch;

// private stuff
static bool is_wiiu_menu;

static inkay_language current_language;
static bool unregister_task_item_pressed;
};

Expand Down
10 changes: 5 additions & 5 deletions plugin/src/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) = nullptr;
static void (*moduleInitialize)(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) {
Expand All @@ -54,7 +54,7 @@ void Inkay_Initialize(bool apply_patches) {
return;
}

moduleInitialize(apply_patches);
moduleInitialize(apply_patches, Config::current_language);
}

void Inkay_Finalize() {
Expand Down
13 changes: 13 additions & 0 deletions src/lang/ko_KR.lang
Original file line number Diff line number Diff line change
@@ -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 모듈 초기화)"
14 changes: 7 additions & 7 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -122,7 +122,7 @@ static InkayStatus Inkay_GetStatus() {
}
}

static void Inkay_Initialize(bool apply_patches) {
static void Inkay_Initialize(bool apply_patches, inkay_language language) {
if (Config::initialized)
return;

Expand Down Expand Up @@ -150,12 +150,12 @@ static void Inkay_Initialize(bool apply_patches) {

DEBUG_FUNCTION_LINE_VERBOSE("Pretendo URL and NoSSL patches applied successfully.");

ShowNotification(get_pretendo_message());
ShowNotification(get_pretendo_message(language));
Config::initialized = true;
} else {
DEBUG_FUNCTION_LINE_VERBOSE("Pretendo URL and NoSSL patches skipped.");

ShowNotification(get_nintendo_network_message());
ShowNotification(get_nintendo_network_message(language));
Config::initialized = true;
return;
}
Expand Down