You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-09 12:50:35 +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:
@@ -39,7 +39,6 @@
|
||||
#include "core/os/os.h"
|
||||
#include "core/string/alt_codes.h"
|
||||
#include "core/string/string_builder.h"
|
||||
#include "core/string/translation_server.h"
|
||||
#include "scene/gui/label.h"
|
||||
#include "scene/main/window.h"
|
||||
#include "scene/theme/theme_db.h"
|
||||
@@ -866,7 +865,7 @@ void TextEdit::_notification(int p_what) {
|
||||
case NOTIFICATION_TRANSLATION_CHANGED:
|
||||
case NOTIFICATION_THEME_CHANGED: {
|
||||
if (is_inside_tree()) {
|
||||
_update_caches();
|
||||
_update_caches(p_what == NOTIFICATION_TRANSLATION_CHANGED);
|
||||
_update_wrap_at_column(true);
|
||||
}
|
||||
} break;
|
||||
@@ -1444,7 +1443,7 @@ void TextEdit::_notification(int p_what) {
|
||||
|
||||
Ref<TextLine> tl;
|
||||
tl.instantiate();
|
||||
tl->add_string(txt, theme_cache.font, theme_cache.font_size);
|
||||
tl->add_string(txt, theme_cache.font, theme_cache.font_size, _get_locale());
|
||||
|
||||
int yofs = ofs_y + (row_height - tl->get_size().y) / 2;
|
||||
if (theme_cache.outline_size > 0 && theme_cache.outline_color.a > 0) {
|
||||
@@ -3357,7 +3356,8 @@ void TextEdit::_update_placeholder() {
|
||||
placeholder_data_buf->set_direction((TextServer::Direction)text_direction);
|
||||
}
|
||||
placeholder_data_buf->set_preserve_control(draw_control_chars);
|
||||
placeholder_data_buf->add_string(placeholder_translated, theme_cache.font, theme_cache.font_size, language);
|
||||
const String &lang = language.is_empty() ? _get_locale() : language;
|
||||
placeholder_data_buf->add_string(placeholder_translated, theme_cache.font, theme_cache.font_size, lang);
|
||||
|
||||
placeholder_bidi_override = structured_text_parser(st_parser, st_args, placeholder_translated);
|
||||
if (placeholder_bidi_override.is_empty()) {
|
||||
@@ -3403,7 +3403,7 @@ void TextEdit::_update_theme_item_cache() {
|
||||
}
|
||||
}
|
||||
|
||||
void TextEdit::_update_caches() {
|
||||
void TextEdit::_update_caches(bool p_invalidate_all) {
|
||||
/* Text properties. */
|
||||
TextServer::Direction dir;
|
||||
if (text_direction == Control::TEXT_DIRECTION_INHERITED) {
|
||||
@@ -3411,11 +3411,16 @@ void TextEdit::_update_caches() {
|
||||
} else {
|
||||
dir = (TextServer::Direction)text_direction;
|
||||
}
|
||||
text.set_direction_and_language(dir, (!language.is_empty()) ? language : TranslationServer::get_singleton()->get_tool_locale());
|
||||
const String &lang = language.is_empty() ? _get_locale() : language;
|
||||
text.set_direction_and_language(dir, lang);
|
||||
text.set_draw_control_chars(draw_control_chars);
|
||||
text.set_font(theme_cache.font);
|
||||
text.set_font_size(theme_cache.font_size);
|
||||
text.invalidate_font();
|
||||
if (p_invalidate_all) {
|
||||
text.invalidate_all();
|
||||
} else {
|
||||
text.invalidate_font();
|
||||
}
|
||||
_update_placeholder();
|
||||
|
||||
/* Syntax highlighting. */
|
||||
@@ -3740,8 +3745,9 @@ void TextEdit::set_text_direction(Control::TextDirection p_text_direction) {
|
||||
} else {
|
||||
dir = (TextServer::Direction)text_direction;
|
||||
}
|
||||
text.set_direction_and_language(dir, (!language.is_empty()) ? language : TranslationServer::get_singleton()->get_tool_locale());
|
||||
text.invalidate_font();
|
||||
const String &lang = language.is_empty() ? _get_locale() : language;
|
||||
text.set_direction_and_language(dir, lang);
|
||||
text.invalidate_all();
|
||||
_update_placeholder();
|
||||
|
||||
if (menu_dir) {
|
||||
@@ -3768,7 +3774,8 @@ void TextEdit::set_language(const String &p_language) {
|
||||
} else {
|
||||
dir = (TextServer::Direction)text_direction;
|
||||
}
|
||||
text.set_direction_and_language(dir, (!language.is_empty()) ? language : TranslationServer::get_singleton()->get_tool_locale());
|
||||
const String &lang = language.is_empty() ? _get_locale() : language;
|
||||
text.set_direction_and_language(dir, lang);
|
||||
text.invalidate_all();
|
||||
_update_placeholder();
|
||||
queue_accessibility_update();
|
||||
|
||||
Reference in New Issue
Block a user