mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Make text-related nodes translation domain aware
- Makes `is_layout_rtl()` translation domain aware - Makes various text-drawing controls translation domain aware - Makes translation preview use the project's fallback locale when disabled
This commit is contained in:
parent
149a4b4ca1
commit
172c80df67
23 changed files with 132 additions and 101 deletions
|
|
@ -35,7 +35,6 @@
|
|||
#include "core/input/input_map.h"
|
||||
#include "core/os/os.h"
|
||||
#include "core/string/string_builder.h"
|
||||
#include "core/string/translation_server.h"
|
||||
#include "scene/gui/scroll_container.h"
|
||||
#include "scene/main/canvas_layer.h"
|
||||
#include "scene/main/window.h"
|
||||
|
|
@ -3516,12 +3515,9 @@ bool Control::is_layout_rtl() const {
|
|||
} else if (proj_root_layout_direction == 2) {
|
||||
data.is_rtl = true;
|
||||
} else if (proj_root_layout_direction == 3) {
|
||||
String locale = OS::get_singleton()->get_locale();
|
||||
data.is_rtl = TS->is_locale_right_to_left(locale);
|
||||
data.is_rtl = TS->is_locale_right_to_left(OS::get_singleton()->get_locale());
|
||||
} else {
|
||||
const Ref<Translation> &t = TranslationServer::get_singleton()->get_translation_object(TranslationServer::get_singleton()->get_locale());
|
||||
String locale = t.is_valid() ? t->get_locale() : TranslationServer::get_singleton()->get_fallback_locale();
|
||||
data.is_rtl = TS->is_locale_right_to_left(locale);
|
||||
data.is_rtl = TS->is_locale_right_to_left(_get_locale());
|
||||
}
|
||||
return data.is_rtl;
|
||||
}
|
||||
|
|
@ -3532,8 +3528,9 @@ bool Control::is_layout_rtl() const {
|
|||
return data.is_rtl;
|
||||
}
|
||||
#endif // TOOLS_ENABLED
|
||||
const StringName domain_name = get_translation_domain();
|
||||
Node *parent_node = get_parent();
|
||||
while (parent_node) {
|
||||
while (parent_node && domain_name == parent_node->get_translation_domain()) {
|
||||
Control *parent_control = Object::cast_to<Control>(parent_node);
|
||||
if (parent_control) {
|
||||
data.is_rtl = parent_control->is_layout_rtl();
|
||||
|
|
@ -3556,22 +3553,19 @@ bool Control::is_layout_rtl() const {
|
|||
String locale = OS::get_singleton()->get_locale();
|
||||
data.is_rtl = TS->is_locale_right_to_left(locale);
|
||||
} else {
|
||||
String locale = TranslationServer::get_singleton()->get_tool_locale();
|
||||
data.is_rtl = TS->is_locale_right_to_left(locale);
|
||||
data.is_rtl = TS->is_locale_right_to_left(_get_locale());
|
||||
}
|
||||
} else if (data.layout_dir == LAYOUT_DIRECTION_APPLICATION_LOCALE) {
|
||||
if (GLOBAL_GET_CACHED(bool, "internationalization/rendering/force_right_to_left_layout_direction")) {
|
||||
data.is_rtl = true;
|
||||
} else {
|
||||
String locale = TranslationServer::get_singleton()->get_tool_locale();
|
||||
data.is_rtl = TS->is_locale_right_to_left(locale);
|
||||
data.is_rtl = TS->is_locale_right_to_left(_get_locale());
|
||||
}
|
||||
} else if (data.layout_dir == LAYOUT_DIRECTION_SYSTEM_LOCALE) {
|
||||
if (GLOBAL_GET_CACHED(bool, "internationalization/rendering/force_right_to_left_layout_direction")) {
|
||||
const_cast<Control *>(this)->data.is_rtl = true;
|
||||
data.is_rtl = true;
|
||||
} else {
|
||||
String locale = OS::get_singleton()->get_locale();
|
||||
const_cast<Control *>(this)->data.is_rtl = TS->is_locale_right_to_left(locale);
|
||||
data.is_rtl = TS->is_locale_right_to_left(OS::get_singleton()->get_locale());
|
||||
}
|
||||
} else {
|
||||
data.is_rtl = (data.layout_dir == LAYOUT_DIRECTION_RTL);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue