1
0
Fork 0
mirror of https://github.com/HamletDuFromage/aio-switch-updater.git synced 2024-11-28 12:22:02 +00:00

switched to borealis' implementation of internationalisation

This commit is contained in:
flb 2020-10-06 00:53:12 +02:00
parent 15fe18b240
commit 7cc2be438a
28 changed files with 255 additions and 320 deletions

2
.gitignore vendored
View file

@ -6,3 +6,5 @@ switch/
*.nacp
*.nro
*.zip
resources/i18n/zh-Hans
resources/i18n/en-GB

View file

@ -45,11 +45,11 @@ DATA := data
INCLUDES := include lib/zipper/include
APP_TITLE := All-in-One Switch Updater
APP_AUTHOR := HamletDuFromage
APP_VERSION := 1.2.0
APP_VERSION := 1.2.1
ROMFS = res
ROMFS := resources
BOREALIS_PATH := lib/borealis
#BOREALIS_RESOURCES := romfs:/borealis/
BOREALIS_RESOURCES := romfs:/
#APP_RESOURCES := romfs:/
#---------------------------------------------------------------------------------
@ -183,7 +183,9 @@ all: $(BUILD)
$(ROMFS):
@[ -d $@ ] || mkdir -p $@
@echo Merging ROMFS...
@cp -ruf $(CURDIR)/$(BOREALIS_PATH)/resources/. $(CURDIR)/$(ROMFS)/borealis/
#@cp -ruf $(CURDIR)/$(BOREALIS_PATH)/resources/. $(CURDIR)/$(ROMFS)/borealis/
cp -ruf $(CURDIR)/$(ROMFS)/i18n/zh-CN/. $(CURDIR)/$(ROMFS)/i18n/zh-Hans/
#cp -ruf $(CURDIR)/$(ROMFS)/i18n/en-US/. $(CURDIR)/$(ROMFS)/i18n/en-GB/
$(BUILD): $(ROMFS)
@[ -d $@ ] || mkdir -p $@

View file

@ -1,7 +1,5 @@
#pragma once
#define APP_LANG "/config/aio-switch-updater/lang.json"
#define ROOT_PATH "/"
#define DOWNLOAD_PATH "/config/aio-switch-updater/"
#define CONFIG_PATH "/config/aio-switch-updater/"
@ -43,6 +41,7 @@
#define PAYLOAD_PATH "/payloads/"
#define BOOTLOADER_PL_PATH "/bootloader/payloads/"
#define UPDATE_BIN_PATH "/bootloader/update.bin"
#define REBOOT_PAYLOAD_PATH "/atmosphere/reboot_payload.bin"
#define LISTITEM_HEIGHT 50

View file

@ -1,36 +0,0 @@
#pragma once
#include <string>
#include <json.hpp>
#include <switch.h>
namespace lang {
enum class Language {
English,
Chinese,
French,
/*
Dutch,
Italian,
German,
Spanish,*/
Default,
};
const nlohmann::json &get_json();
Language get_current_language();
Result set_language(Language lang);
Result initialize_to_system_language();
std::string get_string(std::string key, const nlohmann::json &json = get_json());
namespace literals {
inline std::string operator ""_lang(const char *key, size_t size) {
return get_string(std::string(key, size));
}
} // namespace literals
}; // namespace lang

View file

@ -0,0 +1,11 @@
{
"hints": {
"ok": "OK",
"back": "Back",
"exit": "Exit"
},
"crash_frame": {
"button": "OK"
}
}

View file

@ -32,6 +32,8 @@
"v1_1_3_text": "\uE016 Now displays the latest installed cheat version.\n\uE016 Now warns in the app title if a new update is available.",
"v1_2_0": "v1.2.0",
"v1_2_0_text": "\uE016 Now multilingual (thanks to 'github.com/tiansongyu').\n\uE016 Chinese and French are currently supported.",
"v1_2_1": "v1.2.1",
"v1_2_1_text": "\uE016 Added option to set a payload to /bootloader/update.bin",
"Ok_button": "Ok",
"cheats_page.cpp":"",
@ -119,6 +121,7 @@
"payload_reboot": "Reboot menu",
"payload_select": " Select a payload to reboot to.",
"payload_set": "Set as reboot_payload.bin",
"payload_set_up": "Set as /bootloader/update.bin",
"payload_success": "Successfully copied '",
"payload_to": "' to '",
"payload_ok": "Ok",
@ -133,7 +136,7 @@
"tool_update": "Update the app (v",
"tool_DownLoad": "Downloading:\nAIO-switch-updater\n\nFrom:\n",
"tool_updating": "Updating app",
"tool_downloading":"Downloading...",
"tool_downloading": "Downloading...",
"tool_extracting": "Extracting....",
"tool_all_done": " All done!",
"tool_changelog": "Changelog",

View file

@ -0,0 +1,11 @@
{
"hints": {
"ok": "OK",
"back": "Retour",
"exit": "Quitter"
},
"crash_frame": {
"button": "OK"
}
}

View file

@ -32,7 +32,8 @@
"v1_1_3_text": "\uE016 Now displays the latest installed cheat version.\n\uE016 Now warns in the app title if a new update is available.",
"v1_2_0": "v1.2.0",
"v1_2_0_text": "\uE016 Now multilingual (thanks to 'github.com/tiansongyu').\n\uE016 Chinese and French are currently supported.",
"v1_2_1": "v1.2.1",
"v1_2_1_text": "\uE016 Added option to set a payload to /bootloader/update.bin",
"Ok_button": "Ok",
"cheats_page.cpp":"",
@ -86,9 +87,9 @@
"jc_all_": "Fini! Vous devrez peut-être ancrer/détacher votre Joy-Cons pour que le changement prenne effet",
"list_donwload.cpp":"",
"Getting": "Obtension ",
"firmware_text": "\uE016 Firmware dumps de 'https://darthsternie.net/switch-firmwares/'. Une fois téléchargés, ils seront dans '/firmware'. Vous pouvez ensuite les installer avec Daybreak ou ChoiDuJour.\n\uE016 FW actuel: ",
"currentCeatsver": "\uE016 Cela téléchargera une archive mise à jour quotidiennement des codes de triche de 'gbatemp.net'. Les codes de triche pour les jeux que vous n'avez pas installés ne seront pas extraits sur votre carte SD. Vous pouvez désactiver les mises à jour pour pour une selection de jeux dans le menu 'Outils->Menu de cheat'.\n\uE016 Version actuelle des cheats : ",
"Getting": "Obtention de ",
"firmware_text": "\uE016 Firmware dumps de 'https://darthsternie.net/switch-firmwares/'. Une fois téléchargés, ils seront dans '/firmware'. Vous pouvez ensuite les installer avec Daybreak ou ChoiDuJour.\n\uE016 FW actuel : ",
"currentCeatsver": "\uE016 Archive mise à jour quotidiennement des codes de triche de 'gbatemp.net'. Les codes de triche pour les jeux que vous ne possedez pas ne seront pas extraits sur votre carte SD. Vous pouvez désactiver les mises à jour pour pour une sélection de jeux dans le menu 'Outils->Menu de cheat'.\n\uE016 Version actuelle des cheats : ",
"operation_1": "sigpatches",
"list_sigpatches": "\uE016 Les Sigpatches permettent à votre Switch d'installer et d'exécuter des fichiers NSP non officiels. Assurez-vous de choisir les bons patchs pour votre configuration (Atmosphere pur ou Hekate+Atmosphere).",
"operation_2": "firmware",
@ -100,7 +101,7 @@
"list_latest_ver": "Derniers (ver ",
"list_cheats": "codes de triche",
"list_down": "Télécharger:\n",
"list_from": "\n\nFrom:\n",
"list_from": "\n\nDe:\n",
"list_downing": "Téléchargement...",
"list_extracting": "Exctraction...",
"list_All": "Fini!",
@ -118,8 +119,9 @@
"payload_page.cpp":"",
"payload_reboot": "Menu de redémarrage",
"payload_select": " Selectionner un payload à redémarrer.",
"payload_set": "Définit comme reboot_payload.bin",
"payload_select": " Selectionner un payload à injecter.",
"payload_set": "Déf comme reboot_payload.bin",
"payload_set_up": "Déf comme bootloader/update.bin",
"payload_success": "Copié avec succès '",
"payload_to": "' vers '",
"payload_ok": "Ok",
@ -129,7 +131,7 @@
"tools_tab.cpp":"",
"tool_cheats": "Menu de cheat",
"tool_change": "Changer la couleur des Joy-Cons",
"tool_download": "Télécharger des payloads vers ",
"tool_download": "Télécharger des payloads dans ",
"tool_inject": "Injecter un payload",
"tool_update": "Mettre à jour l'app (v",
"tool_DownLoad": "Télécharger:\nAIO-switch-updater\n\nDe:\n",

View file

@ -0,0 +1,11 @@
{
"hints": {
"ok": "OK",
"back": "Back",
"exit": "Exit"
},
"crash_frame": {
"button": "OK"
}
}

View file

@ -31,6 +31,8 @@
"v1_1_3_text": "\uE016 现在显示最新安装的金手指版本.\n\uE016 如果有新的更新可用,现在在应用程序标题中警告",
"v1_2_0": "v1.2.0",
"v1_2_0_text": "\uE016 现在可以使用多种语言(感谢'github.com/tiansongyu').\n\uE016 目前支持中文和法文.",
"v1_2_1": "v1.2.1",
"v1_2_1_text": "\uE016 Added option to set a payload to /bootloader/update.bin",
"Ok_button": "确定",
"cheats_page.cpp":"",
@ -120,6 +122,7 @@
"payload_reboot": "重启菜单",
"payload_select": "选择一个注入文件重启.",
"payload_set": "设置 reboot_payload.bin",
"payload_set_up": "设置 bootloader/update.bin",
"payload_success": "成功复制 '",
"payload_to": "' to '",
"payload_ok": "确定",

View file

@ -1,25 +1,26 @@
#include "JC_page.hpp"
#include "lang.hpp"
using namespace lang::literals;
namespace i18n = brls::i18n;
using namespace i18n::literals;
JCPage::JCPage() : AppletFrame(true, true)
{
this->setTitle("joy_con"_lang);
this->setTitle("menus/joy_con"_i18n );
list = new brls::List();
std::string labelText = "jc_you_can_1"_lang + std::string(COLOR_PROFILES_PATH) + "jc_you_can_goto"\
"jc_you_can_2"_lang;
std::string labelText = "menus/jc_you_can_1"_i18n + std::string(COLOR_PROFILES_PATH) + "menus/jc_you_can_goto"\
"menus/jc_you_can_2"_i18n ;
label = new brls::Label(brls::LabelStyle::DESCRIPTION, labelText, true);
list->addView(label);
backup = new brls::ListItem("jc_backup"_lang);
backup = new brls::ListItem("menus/jc_backup"_i18n );
backup->getClickEvent()->subscribe([&](brls::View* view) {
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
stagedFrame->setTitle("jc_color"_lang);
stagedFrame->setTitle("menus/jc_color"_i18n );
stagedFrame->addStage(
new WorkerPage(stagedFrame, "jc_backing"_lang,
new WorkerPage(stagedFrame, "menus/jc_backing"_i18n ,
[](){backupJCColor(COLOR_PROFILES_PATH);})
);
stagedFrame->addStage(
new ConfirmPage(stagedFrame, "jc_all_done"_lang, true)
new ConfirmPage(stagedFrame, "menus/jc_all_done"_i18n , true)
);
brls::Application::pushView(stagedFrame);
});
@ -37,13 +38,13 @@ JCPage::JCPage() : AppletFrame(true, true)
items[i] = new brls::ListItem(names[i]);
items[i]->getClickEvent()->subscribe([&, value](brls::View* view) {
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
stagedFrame->setTitle("jc_concolor"_lang);
stagedFrame->setTitle("menus/jc_concolor"_i18n );
stagedFrame->addStage(
new WorkerPage(stagedFrame, "jc_changing"_lang,
new WorkerPage(stagedFrame, "menus/jc_changing"_i18n ,
[value](){changeJCColor(value);})
);
stagedFrame->addStage(
new ConfirmPage(stagedFrame, "jc_all_"_lang, true)
new ConfirmPage(stagedFrame, "menus/jc_all_"_i18n , true)
);
brls::Application::pushView(stagedFrame);
});

View file

@ -1,13 +1,15 @@
#include "about_tab.hpp"
#include "lang.hpp"
using namespace lang::literals;
namespace i18n = brls::i18n;
using namespace i18n::literals;
AboutTab::AboutTab()
{
// Subtitle
brls::Label *subTitle = new brls::Label(
brls::LabelStyle::REGULAR,
"About_Title"_lang ,
"menus/About_Title"_i18n ,
true
);
subTitle->setHorizontalAlign(NVG_ALIGN_CENTER);
@ -16,7 +18,7 @@ AboutTab::AboutTab()
// Copyright
brls::Label *copyright = new brls::Label(
brls::LabelStyle::DESCRIPTION,
"copyright"_lang,
"menus/copyright"_i18n,
true
);
copyright->setHorizontalAlign(NVG_ALIGN_CENTER);
@ -26,8 +28,8 @@ AboutTab::AboutTab()
this->addView(new brls::Header("Disclaimers"));
brls::Label *links = new brls::Label(
brls::LabelStyle::SMALL,
"Disclaimers"_lang,
"menus/Disclaimers"_i18n,
true
);
this->addView(links);
}
}

View file

@ -1,14 +1,15 @@
#include "app_page.hpp"
//TODO: Serialize it in extract.cpp
#include "lang.hpp"
using namespace lang::literals;
namespace i18n = brls::i18n;
using namespace i18n::literals;
AppPage::AppPage() : AppletFrame(true, true)
{
this->setTitle("app_title"_lang);
this->setTitle("menus/app_title"_i18n );
list = new brls::List();
label = new brls::Label(
brls::LabelStyle::DESCRIPTION,
"app_label"_lang,
"menus/app_label"_i18n ,
true
);
list->addView(label);
@ -74,22 +75,22 @@ AppPage::AppPage() : AppletFrame(true, true)
break;
}
text += url;
download = new brls::ListItem("text_download_list"_lang);
download = new brls::ListItem("menus/text_download_list"_i18n );
archiveType type = cheats;
download->getClickEvent()->subscribe([&, url, text, type](brls::View* view) {
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
stagedFrame->setTitle("text_title"_lang);
stagedFrame->setTitle("menus/text_title"_i18n );
stagedFrame->addStage(
new ConfirmPage(stagedFrame, text)
);
stagedFrame->addStage(
new WorkerPage(stagedFrame, "Downloading"_lang, [url, type](){downloadArchive(url, type);})
new WorkerPage(stagedFrame, "menus/Downloading"_i18n , [url, type](){downloadArchive(url, type);})
);
stagedFrame->addStage(
new WorkerPage(stagedFrame, "Extracting"_lang, [type](){extractArchive(type);})
new WorkerPage(stagedFrame, "menus/Extracting"_i18n , [type](){extractArchive(type);})
);
stagedFrame->addStage(
new ConfirmPage(stagedFrame, "All_done"_lang, true)
new ConfirmPage(stagedFrame, "menus/All_done"_i18n , true)
);
brls::Application::pushView(stagedFrame);
});

View file

@ -1,37 +1,41 @@
#include "changelog_page.hpp"
#include "lang.hpp"
using namespace lang::literals;
namespace i18n = brls::i18n;
using namespace i18n::literals;
ChangelogPage::ChangelogPage() : AppletFrame(true, true)
{
this->setTitle("Changelog"_lang);
this->setTitle("menus/Changelog"_i18n );
list = new brls::List();
std::vector<std::string> verTitles;
std::string change;
std::vector<std::string> changes;
verTitles.push_back("v1_0_1"_lang);
changes.push_back("v1_0_1_text"_lang);
verTitles.push_back("menus/v1_0_1"_i18n );
changes.push_back("menus/v1_0_1_text"_i18n );
verTitles.push_back("v1_0_2"_lang);
changes.push_back("v1_0_2_text"_lang);
verTitles.push_back("menus/v1_0_2"_i18n );
changes.push_back("menus/v1_0_2_text"_i18n );
verTitles.push_back("v1_0_3"_lang);
changes.push_back("v1_0_3_text"_lang);
verTitles.push_back("menus/v1_0_3"_i18n );
changes.push_back("menus/v1_0_3_text"_i18n );
verTitles.push_back("v1_1_0"_lang);
changes.push_back("v1_1_0_text"_lang);
verTitles.push_back("menus/v1_1_0"_i18n );
changes.push_back("menus/v1_1_0_text"_i18n );
verTitles.push_back("v1_1_1"_lang);
changes.push_back("v1_1_1_text"_lang);
verTitles.push_back("menus/v1_1_1"_i18n );
changes.push_back("menus/v1_1_1_text"_i18n );
verTitles.push_back("v1_1_2"_lang);
changes.push_back("v1_1_2_text"_lang);
verTitles.push_back("menus/v1_1_2"_i18n );
changes.push_back("menus/v1_1_2_text"_i18n );
verTitles.push_back("v1_1_3"_lang);
changes.push_back("v1_1_3_text"_lang);
verTitles.push_back("menus/v1_1_3"_i18n );
changes.push_back("menus/v1_1_3_text"_i18n );
verTitles.push_back("v1_2_0"_lang);
changes.push_back("v1_2_0_text"_lang);
verTitles.push_back("menus/v1_2_0"_i18n );
changes.push_back("menus/v1_2_0_text"_i18n );
verTitles.push_back("menus/v1_2_1"_i18n );
changes.push_back("menus/v1_2_1_text"_i18n );
int nbVersions = verTitles.size();
items.reserve(nbVersions);
@ -43,7 +47,7 @@ ChangelogPage::ChangelogPage() : AppletFrame(true, true)
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
dialog->close();
};
dialog->addButton("Ok_button"_lang, callback);
dialog->addButton("menus/Ok_button"_i18n , callback);
dialog->setCancelable(true);
dialog->open();
});

View file

@ -1,33 +1,34 @@
#include "cheats_page.hpp"
#include "lang.hpp"
using namespace lang::literals;
namespace i18n = brls::i18n;
using namespace i18n::literals;
CheatsPage::CheatsPage() : AppletFrame(true, true)
{
this->setTitle("cheat_menu"_lang);
this->setTitle("menus/cheat_menu"_i18n );
list = new brls::List();
view = new brls::ListItem("cheat_view"_lang);
view = new brls::ListItem("menus/cheat_view"_i18n );
view->getClickEvent()->subscribe([&](brls::View* view){
brls::Application::pushView(new AppPage());
});
list->addView(view);
exclude = new brls::ListItem("cheat_exclude"_lang);
exclude = new brls::ListItem("menus/cheat_exclude"_i18n );
exclude->getClickEvent()->subscribe([&](brls::View* view){
brls::Application::pushView(new ExcludePage());
});
list->addView(exclude);
deleteCheats = new brls::ListItem("cheat_delete_all_ex"_lang);
deleteCheats = new brls::ListItem("menus/cheat_delete_all_ex"_i18n );
deleteCheats->getClickEvent()->subscribe([&](brls::View* view){
stagedFrame = new brls::StagedAppletFrame();
stagedFrame->setTitle("cheat_delete_all_cheat"_lang);
stagedFrame->setTitle("menus/cheat_delete_all_cheat"_i18n );
stagedFrame->addStage(
new WorkerPage(stagedFrame, "cheat_Deleting"_lang , [](){removeCheats(getCFW());})
new WorkerPage(stagedFrame, "menus/cheat_Deleting"_i18n , [](){removeCheats(getCFW());})
);
stagedFrame->addStage(
new ConfirmPage(stagedFrame, "cheat_All_done"_lang, true)
new ConfirmPage(stagedFrame, "menus/cheat_All_done"_i18n , true)
);
brls::Application::pushView(stagedFrame);
});

View file

@ -1,6 +1,7 @@
#include "choice_page.hpp"
#include "lang.hpp"
using namespace lang::literals;
namespace i18n = brls::i18n;
using namespace i18n::literals;
ChoicePage::ChoicePage(brls::StagedAppletFrame* frame, std::string text)
{
this->yes = (new brls::Button(brls::ButtonStyle::BORDERLESS))->setLabel("yes");

View file

@ -1,9 +1,10 @@
#include "confirm_page.hpp"
#include "lang.hpp"
using namespace lang::literals;
namespace i18n = brls::i18n;
using namespace i18n::literals;
ConfirmPage::ConfirmPage(brls::StagedAppletFrame* frame, std::string text, bool done): done(done)
{
this->button = (new brls::Button(brls::ButtonStyle::BORDERLESS))->setLabel(done ? "Back"_lang: "Continue"_lang);
this->button = (new brls::Button(brls::ButtonStyle::BORDERLESS))->setLabel(done ? "menus/Back"_i18n : "menus/Continue"_i18n );
this->button->setParent(this);
this->button->getClickEvent()->subscribe([frame, this](View* view) {
if (!frame->isLastStage()) frame->nextStage();
@ -16,7 +17,7 @@ ConfirmPage::ConfirmPage(brls::StagedAppletFrame* frame, std::string text, bool
this->label->setHorizontalAlign(NVG_ALIGN_CENTER);
this->label->setParent(this);
this->registerAction("Back"_lang, brls::Key::B, [this] {
this->registerAction("menus/Back"_i18n , brls::Key::B, [this] {
brls::Application::popView();
return true;
});
@ -27,7 +28,7 @@ void ConfirmPage::draw(NVGcontext* vg, int x, int y, unsigned width, unsigned he
if(!this->done){
auto end = std::chrono::high_resolution_clock::now();
auto missing = std::max(1l - std::chrono::duration_cast<std::chrono::seconds>(end - start).count(), 0l);
auto text = std::string("Continue"_lang);
auto text = std::string("menus/Continue"_i18n );
if (missing > 0) {
this->button->setLabel(text + " (" + std::to_string(missing) + ")");
this->button->setState(brls::ButtonState::DISABLED);

View file

@ -1,13 +1,14 @@
#include "download_payload_page.hpp"
#include "lang.hpp"
using namespace lang::literals;
namespace i18n = brls::i18n;
using namespace i18n::literals;
DownloadPayloadPage::DownloadPayloadPage() : AppletFrame(true, true)
{
this->setTitle("Download_payloads"_lang);
this->setTitle("menus/Download_payloads"_i18n );
list = new brls::List();
label = new brls::Label(
brls::LabelStyle::DESCRIPTION,
"select"_lang + std::string(BOOTLOADER_PL_PATH) + "'."_lang,
"menus/select"_i18n + std::string(BOOTLOADER_PL_PATH) + "." ,
true
);
list->addView(label);
@ -18,20 +19,20 @@ DownloadPayloadPage::DownloadPayloadPage() : AppletFrame(true, true)
for (int i = 0; i<nbLinks; i++){
std::string url = std::get<1>(links)[i];
std::string path = std::string(BOOTLOADER_PL_PATH) + std::get<0>(links)[i];
std::string text("Download"_lang + std::get<0>(links)[i] + "from"_lang+ url);
std::string text("menus/Download"_i18n + std::get<0>(links)[i] + "menus/from"_i18n + url);
items[i] = new brls::ListItem(std::get<0>(links)[i]);
items[i]->getClickEvent()->subscribe([&, text, url, path](brls::View* view) {
createTree(BOOTLOADER_PL_PATH);
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
stagedFrame->setTitle("getting_paylaod"_lang);
stagedFrame->setTitle("menus/getting_paylaod"_i18n );
stagedFrame->addStage(
new ConfirmPage(stagedFrame, text)
);
stagedFrame->addStage(
new WorkerPage(stagedFrame, "down"_lang, [url, path](){downloadFile(url.c_str(), path.c_str(), OFF);})
new WorkerPage(stagedFrame, "menus/down"_i18n , [url, path](){downloadFile(url.c_str(), path.c_str(), OFF);})
);
stagedFrame->addStage(
new ConfirmPage(stagedFrame, "download_all_done"_lang, true)
new ConfirmPage(stagedFrame, "menus/download_all_done"_i18n , true)
);
brls::Application::pushView(stagedFrame);
});
@ -41,12 +42,12 @@ DownloadPayloadPage::DownloadPayloadPage() : AppletFrame(true, true)
else{
notFound = new brls::Label(
brls::LabelStyle::DESCRIPTION,
"description"_lang,
"menus/description"_i18n ,
true
);
notFound->setHorizontalAlign(NVG_ALIGN_CENTER);
list->addView(notFound);
brls::ListItem* back = new brls::ListItem("back"_lang);
brls::ListItem* back = new brls::ListItem("menus/back"_i18n );
back->getClickEvent()->subscribe([&](brls::View* view) {
brls::Application::popView();
});

View file

@ -1,13 +1,14 @@
#include "exclude_page.hpp"
#include "lang.hpp"
using namespace lang::literals;
namespace i18n = brls::i18n;
using namespace i18n::literals;
ExcludePage::ExcludePage() : AppletFrame(true, true)
{
this->setTitle("exclude_titles"_lang);
this->setTitle("menus/exclude_titles"_i18n );
list = new brls::List();
label = new brls::Label(
brls::LabelStyle::DESCRIPTION,
"you_can"_lang,
"menus/you_can"_i18n ,
true
);
list->addView(label);
@ -66,7 +67,7 @@ ExcludePage::ExcludePage() : AppletFrame(true, true)
i++;
}
list->registerAction("save"_lang, brls::Key::B, [this] {
list->registerAction("menus/save"_i18n , brls::Key::B, [this] {
std::set<std::string> exclude{};
for(int i = 0; i < (int) std::get<1>(items).size(); i++){
if(!std::get<0>(items)[i]->getToggleState()){

View file

@ -1,8 +1,9 @@
#include "extract.hpp"
#include "utils.hpp"
#include "download.hpp"
#include "lang.hpp"
using namespace lang::literals;
namespace i18n = brls::i18n;
using namespace i18n::literals;
void extract(const char * filename, const char* workingPath, int overwriteInis){
ProgressEvent::instance().reset();
ProgressEvent::instance().setStep(1);

View file

@ -1,114 +0,0 @@
#include <switch.h>
#include "json.hpp"
#include "lang.hpp"
#include <filesystem>
#include <fstream>
using json = nlohmann::json;
namespace lang {
namespace {
static json lang_json = nullptr;
static Language current_language = Language::Default;
} // namespace
const json &get_json() {
return lang_json;
}
Language get_current_language() {
return current_language;
}
Result set_language(Language lang) {
const char *path;
current_language = lang;
switch (lang) {
case Language::Chinese:
path = "romfs:/lang/ch.json";
break;
//if you need add a new language
//use it !
case Language::French:
path = "romfs:/lang/fr.json";
break;
/*
case Language::Dutch:
path = "romfs:/lang/nl.json";
break;
case Language::Italian:
path = "romfs:/lang/it.json";
break;
case Language::German:
path = "romfs:/lang/de.json";
break;
case Language::Spanish:
path = "romfs:/lang/es.json";
break;*/
case Language::English:
case Language::Default:
default:
path = "romfs:/lang/en.json";
break;
}
std::fstream langFile;
if(std::filesystem::exists(path)){
langFile.open(path, std::fstream::in);
langFile >> lang_json;
langFile.close();
}
return 0;
}
Result initialize_to_system_language() {
if (auto rc = setInitialize(); R_FAILED(rc)) {
setExit();
return rc;
}
u64 l;
if (auto rc = setGetSystemLanguage(&l); R_FAILED(rc)) {
setExit();
return rc;
}
SetLanguage sl;
if (auto rc = setMakeLanguage(l, &sl); R_FAILED(rc)) {
setExit();
return rc;
}
switch (sl) {
case SetLanguage_ENGB:
case SetLanguage_ENUS:
return set_language(Language::English);
case SetLanguage_ZHCN:
case SetLanguage_ZHHANS:
return set_language(Language::Chinese);
//if you need add a new language
//use it !
case SetLanguage_FR:
return set_language(Language::French);
/*
case SetLanguage_NL:
return set_language(Language::Dutch);
case SetLanguage_IT:
return set_language(Language::Italian);
case SetLanguage_DE:
return set_language(Language::German);
case SetLanguage_ES:
return set_language(Language::Spanish);*/
default:
return set_language(Language::Default);
}
}
std::string get_string(std::string key, const json &json) {
return json.value(key, key);
}
} // namespace lang

View file

@ -1,13 +1,14 @@
#include "language_option_page.hpp"
#include "lang.hpp"
#include <cstdio>
using namespace lang::literals;
namespace i18n = brls::i18n;
using namespace i18n::literals;
//this page is for language page
LanguageOptionPage::LanguageOptionPage() : AppletFrame(true, true)
{
this->setTitle("Language_Option"_lang);
/* this->setTitle("menus/Language_Option"_i18n );
list = new brls::List();
English = new brls::ListItem("English");
@ -20,7 +21,7 @@ LanguageOptionPage::LanguageOptionPage() : AppletFrame(true, true)
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
stagedFrame->addStage(
new ConfirmPage(stagedFrame, "reset_machine"_lang, true)
new ConfirmPage(stagedFrame, "menus/reset_machine"_i18n , true)
);
brls::Application::pushView(stagedFrame);
@ -35,7 +36,7 @@ LanguageOptionPage::LanguageOptionPage() : AppletFrame(true, true)
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
stagedFrame->addStage(
new ConfirmPage(stagedFrame, "reset_machine"_lang, true)
new ConfirmPage(stagedFrame, "menus/reset_machine"_i18n , true)
);
brls::Application::pushView(stagedFrame);
});
@ -50,10 +51,10 @@ LanguageOptionPage::LanguageOptionPage() : AppletFrame(true, true)
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
stagedFrame->addStage(
new ConfirmPage(stagedFrame, "reset_machine"_lang, true)
new ConfirmPage(stagedFrame, "menus/reset_machine"_i18n , true)
);
brls::Application::pushView(stagedFrame);
});
list->addView(French);
this->setContentView(list);
this->setContentView(list); */
}

View file

@ -1,50 +1,52 @@
#include "list_download_tab.hpp"
#include "lang.hpp"
using namespace lang::literals;
namespace i18n = brls::i18n;
using namespace i18n::literals;
ListDownloadTab::ListDownloadTab(archiveType type) :
brls::List()
{
std::tuple<std::vector<std::string>, std::vector<std::string>> links;
std::string operation = "Getting"_lang;
std::string firmwareText("firmware_text"_lang
std::string operation = "menus/Getting"_i18n ;
std::string firmwareText("menus/firmware_text"_i18n
);
std::string currentCheatsVer =
"currentCeatsver"_lang;
"menus/currentCeatsver"_i18n ;
this->description = new brls::Label(brls::LabelStyle::DESCRIPTION, "", true);
switch(type){
case sigpatches:
links = fetchLinks(SIGPATCHES_URL);
operation += "operation_1"_lang;
operation += "menus/operation_1"_i18n ;
this->description->setText(
"list_sigpatches"_lang
"menus/list_sigpatches"_i18n
);
break;
case fw:
links = fetchLinks(FIRMWARE_URL);
operation += "operation_2"_lang;
operation += "menus/operation_2"_i18n ;
SetSysFirmwareVersion ver;
if (R_SUCCEEDED(setsysGetFirmwareVersion(&ver))) firmwareText += ver.display_version;
else firmwareText += "list_not"_lang;
else firmwareText += "menus/list_not"_i18n ;
this->description->setText(firmwareText);
break;
case app:
std::get<0>(links).push_back("list_latest"_lang);
std::get<0>(links).push_back("menus/list_latest"_i18n );
std::get<1>(links).push_back(APP_URL);
operation += "list_app"_lang;
operation += "menus/list_app"_i18n ;
break;
case cfw:
links = fetchLinks(CFW_URL);
operation += "list_cfw"_lang;
operation += "menus/list_cfw"_i18n ;
this->description->setText(
"list_main"_lang
"menus/list_main"_i18n
);
break;
case cheats:
std::string cheatsVer = fetchTitle(CHEATS_RELEASE_URL);
if(cheatsVer != "-1"){
std::get<0>(links).push_back("list_latest_ver"_lang + cheatsVer + ")");
std::get<0>(links).push_back("menus/list_latest_ver"_i18n + cheatsVer + ")");
switch(getCFW()){
case sxos:
std::get<1>(links).push_back(CHEATS_URL_TITLES);
@ -57,7 +59,7 @@ ListDownloadTab::ListDownloadTab(archiveType type) :
break;
}
}
operation += "list_cheats"_lang;
operation += "menus/list_cheats"_i18n ;
currentCheatsVer += readVersion(CHEATS_VERSION);
this->description->setText(currentCheatsVer);
break;
@ -71,7 +73,7 @@ ListDownloadTab::ListDownloadTab(archiveType type) :
linkItems.reserve(nbLinks);
for (int i = 0; i<nbLinks; i++){
std::string url = std::get<1>(links)[i];
std::string text("list_down"_lang + std::get<0>(links)[i] + "list_from"_lang + url);
std::string text("menus/list_down"_i18n + std::get<0>(links)[i] + "menus/list_from"_i18n + url);
linkItems[i] = new brls::ListItem(std::get<0>(links)[i]);
linkItems[i]->setHeight(LISTITEM_HEIGHT);
linkItems[i]->getClickEvent()->subscribe([&, text, url, type, operation](brls::View* view) {
@ -81,13 +83,13 @@ ListDownloadTab::ListDownloadTab(archiveType type) :
new ConfirmPage(stagedFrame, text)
);
stagedFrame->addStage(
new WorkerPage(stagedFrame, "list_downing"_lang, [url, type](){downloadArchive(url, type);})
new WorkerPage(stagedFrame, "menus/list_downing"_i18n , [url, type](){downloadArchive(url, type);})
);
stagedFrame->addStage(
new WorkerPage(stagedFrame, "list_extracting"_lang, [type](){extractArchive(type);})
new WorkerPage(stagedFrame, "menus/list_extracting"_i18n , [type](){extractArchive(type);})
);
stagedFrame->addStage(
new ConfirmPage(stagedFrame, "list_All"_lang, true)
new ConfirmPage(stagedFrame, "menus/list_All"_i18n , true)
);
brls::Application::pushView(stagedFrame);
});
@ -97,7 +99,7 @@ ListDownloadTab::ListDownloadTab(archiveType type) :
else{
notFound = new brls::Label(
brls::LabelStyle::DESCRIPTION,
"list_could_done"_lang,
"menus/list_could_done"_i18n ,
true
);
notFound->setHorizontalAlign(NVG_ALIGN_CENTER);

View file

@ -8,7 +8,7 @@
#include "main_frame.hpp"
#include "constants.hpp"
#include "utils.hpp"
#include "lang.hpp"
#include <string.h>
#include <stdio.h>
@ -20,6 +20,10 @@
#include <sstream>
#include<fstream>
namespace i18n = brls::i18n;
using namespace i18n::literals;
int main(int argc, char* argv[])
{
// Init the app
@ -28,7 +32,8 @@ int main(int argc, char* argv[])
brls::Logger::error("Unable to init Borealis application");
return EXIT_FAILURE;
}
i18n::loadTranslations();
// Setup verbose logging on PC
#ifndef __SWITCH__
brls::Logger::setLogLevel(brls::LogLevel::DEBUG);
@ -46,10 +51,12 @@ int main(int argc, char* argv[])
splInitialize();
createTree(CONFIG_PATH);
brls::Logger::setLogLevel(brls::LogLevel::DEBUG);
brls::Logger::debug("Start");
//start code by tiansongyu
/* //start code by tiansongyu
if(std::filesystem::exists(APP_LANG))
{
std::ifstream i(APP_LANG);
@ -69,7 +76,7 @@ int main(int argc, char* argv[])
std::ofstream o(APP_LANG);
o<<std::setw(4)<<json_file<<std::endl;
}
//end by tiansongyu
//end by tiansongyu */
// Create root view
MainFrame *mainFrame = new MainFrame();

View file

@ -1,23 +1,26 @@
#include "main_frame.hpp"
#include "lang.hpp"
using namespace lang::literals;
namespace i18n = brls::i18n;
using namespace i18n::literals;
MainFrame::MainFrame() : TabFrame()
{
std::string tag = getLatestTag(TAGS_INFO);
if(!tag.empty() && tag != APP_VERSION)
setTitle(std::string(APP_TITLE) + "main_app"_lang);
setTitle(std::string(APP_TITLE) + "menus/main_app"_i18n );
else
setTitle(std::string(APP_TITLE) + "main_v"_lang + std::string(APP_VERSION));
this->addTab("main_about"_lang, new AboutTab());
setTitle(std::string(APP_TITLE) + "menus/main_v"_i18n + std::string(APP_VERSION));
this->addTab("menus/main_about"_i18n , new AboutTab());
this->addSeparator();
this->addTab("main_update_cfw"_lang, new ListDownloadTab(cfw));
this->addTab("main_update_si"_lang, new ListDownloadTab(sigpatches));
this->addTab("main_firmwares"_lang, new ListDownloadTab(fw));
this->addTab("main_cheats"_lang, new ListDownloadTab(cheats));
this->addTab("menus/main_update_cfw"_i18n , new ListDownloadTab(cfw));
this->addTab("menus/main_update_si"_i18n , new ListDownloadTab(sigpatches));
this->addTab("menus/main_firmwares"_i18n , new ListDownloadTab(fw));
this->addTab("menus/main_cheats"_i18n , new ListDownloadTab(cheats));
this->addSeparator();
this->addTab("main_tools"_lang, new ToolsTab(tag));
this->addTab("menus/main_tools"_i18n , new ToolsTab(tag));
}

View file

@ -1,14 +1,15 @@
#include "payload_page.hpp"
#include "lang.hpp"
using namespace lang::literals;
namespace i18n = brls::i18n;
using namespace i18n::literals;
PayloadPage::PayloadPage() : AppletFrame(true, true)
{
CFW cfw = getCFW();
this->setTitle("payload_reboot"_lang);
this->setTitle("menus/payload_reboot"_i18n );
list = new brls::List();
label = new brls::Label(
brls::LabelStyle::DESCRIPTION,
"payload_select"_lang,
"menus/payload_select"_i18n ,
true
);
list->addView(label);
@ -23,32 +24,43 @@ PayloadPage::PayloadPage() : AppletFrame(true, true)
brls::Application::popView();
});
if(cfw == ams){
items[i]->registerAction("payload_set"_lang, brls::Key::X, [this, payload] {
items[i]->registerAction("menus/payload_set"_i18n , brls::Key::X, [this, payload] {
if(R_SUCCEEDED(CopyFile(payload.c_str(), REBOOT_PAYLOAD_PATH))){
brls::Dialog* dialog = new brls::Dialog("payload_success"_lang + payload + "payload_to"_lang + std::string(REBOOT_PAYLOAD_PATH) + "'.");
brls::Dialog* dialog = new brls::Dialog("menus/payload_success"_i18n + payload + "menus/payload_to"_i18n + std::string(REBOOT_PAYLOAD_PATH) + "'.");
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
dialog->close();
};
dialog->addButton("payload_ok"_lang, callback);
dialog->addButton("menus/payload_ok"_i18n , callback);
dialog->setCancelable(true);
dialog->open();
}
return true;
});
}
items[i]->registerAction("menus/payload_set_up"_i18n , brls::Key::Y, [this, payload] {
if(R_SUCCEEDED(CopyFile(payload.c_str(), UPDATE_BIN_PATH))){
brls::Dialog* dialog = new brls::Dialog("menus/payload_success"_i18n + payload + "menus/payload_to"_i18n + std::string(UPDATE_BIN_PATH) + "'.");
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
dialog->close();
};
dialog->addButton("menus/payload_ok"_i18n , callback);
dialog->setCancelable(true);
dialog->open();
}
return true;
});
list->addView(items[i]);
}
list->addView(new brls::ListItemGroupSpacing(true));
shutDown = new brls::ListItem("payload_shut"_lang);
shutDown = new brls::ListItem("menus/payload_shut"_i18n );
shutDown->getClickEvent()->subscribe([](brls::View* view) {
shut_down(false);
brls::Application::popView();
});
list->addView(shutDown);
reboot = new brls::ListItem("payload_reboot_2"_lang);
reboot = new brls::ListItem("menus/payload_reboot_2"_i18n );
reboot->getClickEvent()->subscribe([](brls::View* view) {
shut_down(true);
brls::Application::popView();

View file

@ -1,29 +1,30 @@
#include "tools_tab.hpp"
#include "lang.hpp"
using namespace lang::literals;
namespace i18n = brls::i18n;
using namespace i18n::literals;
ToolsTab::ToolsTab(std::string tag) : brls::List()
{
cheats = new brls::ListItem("tool_cheats"_lang);
cheats = new brls::ListItem("menus/tool_cheats"_i18n );
cheats->getClickEvent()->subscribe([&](brls::View* view){
brls::Application::pushView(new CheatsPage());
});
cheats->setHeight(LISTITEM_HEIGHT);
this->addView(cheats);
JCcolor = new brls::ListItem("tool_change"_lang);
JCcolor = new brls::ListItem("menus/tool_change"_i18n );
JCcolor->getClickEvent()->subscribe([&](brls::View* view){
brls::Application::pushView(new JCPage());
});
JCcolor->setHeight(LISTITEM_HEIGHT);
this->addView(JCcolor);
downloadPayload = new brls::ListItem("tool_download"_lang + std::string(BOOTLOADER_PL_PATH));
downloadPayload = new brls::ListItem("menus/tool_download"_i18n + std::string(BOOTLOADER_PL_PATH));
downloadPayload->getClickEvent()->subscribe([&](brls::View* view){
brls::Application::pushView(new DownloadPayloadPage());
});
this->addView(downloadPayload);
rebootPayload = new brls::ListItem("tool_inject"_lang);
rebootPayload = new brls::ListItem("menus/tool_inject"_i18n );
rebootPayload->getClickEvent()->subscribe([&](brls::View* view){
brls::Application::pushView(new PayloadPage());
});
@ -31,22 +32,22 @@ ToolsTab::ToolsTab(std::string tag) : brls::List()
this->addView(rebootPayload);
if(!tag.empty() && tag != APP_VERSION){
updateApp = new brls::ListItem("tool_update"_lang + tag +")");
std::string text("tool_DownLoad"_lang + std::string(APP_URL));
updateApp = new brls::ListItem("menus/tool_update"_i18n + tag +")");
std::string text("menus/tool_DownLoad"_i18n + std::string(APP_URL));
updateApp->getClickEvent()->subscribe([&, text](brls::View* view) {
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
stagedFrame->setTitle("tool_updating"_lang);
stagedFrame->setTitle("menus/tool_updating"_i18n );
stagedFrame->addStage(
new ConfirmPage(stagedFrame, text)
);
stagedFrame->addStage(
new WorkerPage(stagedFrame, "tool_downloading"_lang, [](){downloadArchive(APP_URL, app);})
new WorkerPage(stagedFrame, "menus/tool_downloading"_i18n , [](){downloadArchive(APP_URL, app);})
);
stagedFrame->addStage(
new WorkerPage(stagedFrame, "tool_extracting"_lang, [](){extractArchive(app);})
new WorkerPage(stagedFrame, "menus/tool_extracting"_i18n , [](){extractArchive(app);})
);
stagedFrame->addStage(
new ConfirmPage(stagedFrame, "tool_all_done"_lang, true)
new ConfirmPage(stagedFrame, "menus/tool_all_done"_i18n , true)
);
brls::Application::pushView(stagedFrame);
});
@ -54,17 +55,17 @@ ToolsTab::ToolsTab(std::string tag) : brls::List()
this->addView(updateApp);
}
changelog = new brls::ListItem("tool_changelog"_lang);
changelog = new brls::ListItem("menus/tool_changelog"_i18n );
changelog->getClickEvent()->subscribe([&](brls::View* view){
brls::Application::pushView(new ChangelogPage());
});
changelog->setHeight(LISTITEM_HEIGHT);
this->addView(changelog);
language = new brls::ListItem("Language_Option"_lang);
/* language = new brls::ListItem("menus/Language_Option"_i18n );
language->getClickEvent()->subscribe([&](brls::View* view){
brls::Application::pushView(new LanguageOptionPage());
});
language->setHeight(LISTITEM_HEIGHT);
this->addView(language);
this->addView(language); */
}

View file

@ -1,6 +1,7 @@
#include "utils.hpp"
#include "lang.hpp"
using namespace lang::literals;
namespace i18n = brls::i18n;
using namespace i18n::literals;
bool isServiceRunning(const char *serviceName) {
Handle handle;
SmServiceName service_name = smEncodeName(serviceName);
@ -69,7 +70,7 @@ void downloadArchive(std::string url, archiveType type){
downloadFile(url.c_str(), FIRMWARE_FILENAME, OFF);
}
else{
showDialogBox("utils_because"_lang, "utils_ok"_lang);
showDialogBox("menus/utils_because"_i18n , "utils_ok"_i18n );
brls::Application::pushView(new MainFrame());
}
break;
@ -134,7 +135,7 @@ void extractArchive(archiveType type){
std::string backup(HEKATE_IPL_PATH);
backup += ".old";
if(std::filesystem::exists(HEKATE_IPL_PATH)){
overwriteInis = showDialogBox("utils_do"_lang + std::string(HEKATE_IPL_PATH) +"?", "utils_no"_lang, "utils_yes"_lang);
overwriteInis = showDialogBox("menus/utils_do"_i18n + std::string(HEKATE_IPL_PATH) +"?", "menus/utils_no"_i18n , "menus/utils_yes"_i18n );
if(overwriteInis == 0){
extract(SIGPATCHES_FILENAME, ROOT_PATH, HEKATE_IPL_PATH);
}
@ -147,7 +148,7 @@ void extractArchive(archiveType type){
}
}
else{
showDialogBox("utils_the"_lang, "utils_ok"_lang);
showDialogBox("menus/utils_the"_i18n , "menus/utils_ok"_i18n );
brls::Application::pushView(new MainFrame());
}
break;
@ -158,7 +159,7 @@ void extractArchive(archiveType type){
break;
case fw:
if(std::filesystem::file_size(FIRMWARE_FILENAME) < 200000){
showDialogBox("utils_the_downloaded"_lang, "utils_ok"_lang);
showDialogBox("menus/utils_the_downloaded"_i18n , "menus/utils_ok"_i18n );
brls::Application::pushView(new MainFrame());
}
else{
@ -172,11 +173,11 @@ void extractArchive(archiveType type){
break;
case cfw:
if(isArchive(CFW_FILENAME)){
overwriteInis = showDialogBox("ultils_overwrite"_lang, "utils_no"_lang, "utils_yes"_lang);
overwriteInis = showDialogBox("menus/ultils_overwrite"_i18n , "menus/utils_no"_i18n , "menus/utils_yes"_i18n );
extract(CFW_FILENAME, ROOT_PATH, overwriteInis);
}
else{
showDialogBox("ultis_file"_lang, "utils_ok"_lang);
showDialogBox("menus/ultis_file"_i18n , "menus/utils_ok"_i18n );
brls::Application::pushView(new MainFrame());
}
break;