Skip to content

Commit d8cdc53

Browse files
committed
Use language command line argument to override editor locale.
1 parent 9edc290 commit d8cdc53

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

editor/settings/editor_settings.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#include "editor/inspector/editor_property_name_processor.h"
5151
#include "editor/project_manager/engine_update_label.h"
5252
#include "editor/translations/editor_translation.h"
53+
#include "main/main.h"
5354
#include "modules/regex/regex.h"
5455
#include "scene/gui/color_picker.h"
5556
#include "scene/main/node.h"
@@ -79,7 +80,7 @@ bool EditorSettings::_set(const StringName &p_name, const Variant &p_value) {
7980
emit_signal(SNAME("settings_changed"));
8081

8182
if (p_name == SNAME("interface/editor/editor_language")) {
82-
setup_language();
83+
setup_language(false);
8384
}
8485
}
8586
return true;
@@ -1289,7 +1290,7 @@ void EditorSettings::create() {
12891290

12901291
print_verbose("EditorSettings: Load OK!");
12911292

1292-
singleton->setup_language();
1293+
singleton->setup_language(true);
12931294
singleton->setup_network();
12941295
singleton->load_favorites_and_recent_dirs();
12951296
singleton->update_text_editor_themes_list();
@@ -1316,13 +1317,19 @@ void EditorSettings::create() {
13161317
singleton->set_path(config_file_path, true);
13171318
singleton->save_changed_setting = true;
13181319
singleton->_load_defaults(extra_config);
1319-
singleton->setup_language();
1320+
singleton->setup_language(true);
13201321
singleton->setup_network();
13211322
singleton->update_text_editor_themes_list();
13221323
}
13231324

1324-
void EditorSettings::setup_language() {
1325+
void EditorSettings::setup_language(bool p_initial_setup) {
13251326
String lang = _EDITOR_GET("interface/editor/editor_language");
1327+
if (p_initial_setup) {
1328+
String lang_ov = Main::get_locale_override();
1329+
if (!lang_ov.is_empty()) {
1330+
lang = lang_ov;
1331+
}
1332+
}
13261333

13271334
if (lang == "en") {
13281335
TranslationServer::get_singleton()->set_locale(lang);

editor/settings/editor_settings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class EditorSettings : public Resource {
138138
static String get_newest_settings_path();
139139

140140
static void create();
141-
void setup_language();
141+
void setup_language(bool p_initial_setup);
142142
void setup_network();
143143
static void save();
144144
static void destroy();

main/main.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
10941094
arg == "--display-driver" ||
10951095
arg == "--rendering-method" ||
10961096
arg == "--rendering-driver" ||
1097-
arg == "--xr-mode") {
1097+
arg == "--xr-mode" ||
1098+
arg == "-l" ||
1099+
arg == "--language") {
10981100
if (N) {
10991101
forwardable_cli_arguments[CLI_SCOPE_TOOL].push_back(arg);
11001102
forwardable_cli_arguments[CLI_SCOPE_TOOL].push_back(N->get());
@@ -3842,6 +3844,10 @@ String Main::get_rendering_driver_name() {
38423844
return rendering_driver;
38433845
}
38443846

3847+
String Main::get_locale_override() {
3848+
return locale;
3849+
}
3850+
38453851
// everything the main loop needs to know about frame timings
38463852
static MainTimerSync main_timer_sync;
38473853

main/main.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class Main {
7171
static Error setup(const char *execpath, int argc, char *argv[], bool p_second_phase = true);
7272
static Error setup2(bool p_show_boot_logo = true); // The thread calling setup2() will effectively become the main thread.
7373
static String get_rendering_driver_name();
74+
static String get_locale_override();
7475
static void setup_boot_logo();
7576
#ifdef TESTS_ENABLED
7677
static Error test_setup();

0 commit comments

Comments
 (0)