fix(shellui): apply system language after dropping ptrace

This commit is contained in:
aydencharles committed 2026-09-09 18:43:31 +08:00
1 parent a6c0d9cea6
commit 00e924f0bd
4 files changed
+71 -13

No files matched your search

+4 -2
View File
@@ -44,8 +44,10 @@ void apply_ui_lang(int ui_lang);
/**
* Apply the stored UI language setting.
* 0=system, 1=zh-Hans, 2=en, 3=ar, 4=zh-Hant, 5=ja, 6=fr, 7=de, 8=ko,
* 9=es, 10=pt-BR, 11=it, 12=ru, 13=pl, 14=th. This is a configuration
* boundary: system is queried here once, then XML and notifications
* 9=es, 10=pt-BR, 11=it, 12=ru, 13=pl, 14=th.
* 0 queries SCE_SYSTEM_SERVICE_PARAM_ID_LANG. Call this only when
* SystemService can answer (not under PTRACE_AUTHID). A failed query
* leaves the current language unchanged; XML and notifications then
* reuse the resolved language.
*/
void apply_system_or_ui_lang(int ui_lang);
+4
View File
@@ -25,6 +25,7 @@ along with this program; see the file COPYING. If not, see
#include "plugin_ui_bridge_client.hpp"
#include "proc.h"
#include "ps5/kernel.h"
#include "toolbox_i18n.hpp"
#include "ucred.h"
#include "webserver.hpp"
@@ -791,6 +792,9 @@ int main(int argc, char const* argv[]) {
LOG_DEBUG("Performed Magic");
setup_proc_hooks();
/* SystemService cannot be queried under PTRACE_AUTHID. */
toolbox_i18n::apply_system_or_ui_lang(g_settings.ui_lang);
shellui_hooks_publish_ready();
/*
* Home already cached pre-inject state. Display-TID spoof and the top-nav
+28 -6
View File
@@ -1,9 +1,12 @@
/* Copyright (C) 2025 OnionHEN / LightningMods */
#include "toolbox_i18n.hpp"
#include <onion/log.h>
#include <onion/notify_i18n.h>
#ifndef ONION_HOST_TEST
#ifdef ONION_HOST_TEST
extern "C" int sceSystemServiceParamGetInt(int param_id, int *value);
#else
#include "external_symbols.hpp"
#endif
@@ -170,6 +173,24 @@ int locale_index_for_lang(Lang lang) {
return kI18nLocaleFallback;
}
/* SCE_SYSTEM_SERVICE_PARAM_ID_LANG */
constexpr int kSystemServiceParamIdLang = 1;
bool read_system_language(int *out) {
#ifndef ONION_HOST_TEST
if (!sceSystemServiceParamGetInt)
return false;
#endif
int language = 0;
const int result =
sceSystemServiceParamGetInt(kSystemServiceParamIdLang, &language);
if (result < 0 || language < 0)
return false;
if (out)
*out = language;
return true;
}
} // namespace
Lang active_lang() { return lang_from_notify(onion_notify_get_language()); }
@@ -225,11 +246,12 @@ void apply_system_or_ui_lang(int ui_lang) {
return;
}
int system_language = 1;
#ifndef ONION_HOST_TEST
if (sceSystemServiceParamGetInt)
(void)sceSystemServiceParamGetInt(1, &system_language);
#endif
int system_language = 0;
if (!read_system_language(&system_language)) {
LOG_WARN("system language query failed; keeping %d",
static_cast<int>(active_lang()));
return;
}
set_lang(lang_from_notify(onion_notify_resolve_language(0, system_language)));
}
+35 -5
View File
@@ -7,6 +7,8 @@
#include <cstring>
#include <string>
extern "C" void onion_test_system_language_configure(int result, int value);
using namespace toolbox_i18n;
static int test_default_zh(void) {
@@ -308,11 +310,37 @@ static int test_apply_ui_lang(void) {
return 0;
}
static int test_system_lang_host_fallback(void) {
apply_system_or_ui_lang(2);
TEST_ASSERT_TRUE(active_lang() == Lang::En);
static int test_system_lang_follows_query(void) {
onion_test_system_language_configure(0, 11);
apply_system_or_ui_lang(0);
TEST_ASSERT_TRUE(active_lang() == Lang::ZhHans);
onion_test_system_language_configure(0, 1);
apply_system_or_ui_lang(0);
TEST_ASSERT_TRUE(active_lang() == Lang::En);
apply_system_or_ui_lang(2);
TEST_ASSERT_TRUE(active_lang() == Lang::En);
onion_test_system_language_configure(0, 11);
apply_system_or_ui_lang(2);
TEST_ASSERT_TRUE(active_lang() == Lang::En);
onion_test_system_language_configure(0, 1);
return 0;
}
static int test_system_lang_query_failure_keeps_current(void) {
set_lang(Lang::ZhHans);
onion_test_system_language_configure(-1, 1);
apply_system_or_ui_lang(0);
TEST_ASSERT_TRUE(active_lang() == Lang::ZhHans);
set_lang(Lang::En);
onion_test_system_language_configure(-1, 11);
apply_system_or_ui_lang(0);
TEST_ASSERT_TRUE(active_lang() == Lang::En);
onion_test_system_language_configure(0, 1);
return 0;
}
@@ -386,8 +414,10 @@ extern "C" int test_toolbox_i18n_suite(void) {
fails += onion_test_run("i18n.pl", test_pl);
fails += onion_test_run("i18n.th", test_th);
fails += onion_test_run("i18n.apply_ui_lang", test_apply_ui_lang);
fails += onion_test_run("i18n.system_lang_host_fallback",
test_system_lang_host_fallback);
fails += onion_test_run("i18n.system_lang_follows_query",
test_system_lang_follows_query);
fails += onion_test_run("i18n.system_lang_query_failure_keeps_current",
test_system_lang_query_failure_keeps_current);
fails += onion_test_run("i18n.missing_key", test_missing_key);
fails += onion_test_run("i18n.format", test_format);
return fails;