Merge pull request #110378 from timothyqiu/rtl-preview
Make text-related nodes translation domain aware
This commit is contained in:
@ -36,7 +36,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"
|
||||
@ -3548,12 +3547,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;
|
||||
}
|
||||
@ -3564,8 +3560,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();
|
||||
@ -3588,22 +3585,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);
|
||||
|
||||
Reference in New Issue
Block a user