diff --git a/core/translation.cpp b/core/translation.cpp index 58f888352ec..ba92c840f32 100644 --- a/core/translation.cpp +++ b/core/translation.cpp @@ -871,6 +871,10 @@ void Translation::add_message(const StringName &p_src_text, const StringName &p_ translation_map[p_src_text] = p_xlated_text; } StringName Translation::get_message(const StringName &p_src_text) const { + if (get_script_instance()) { + return get_script_instance()->call("_get_message", p_src_text); + } + const Map::Element *E = translation_map.find(p_src_text); if (!E) { return StringName(); @@ -904,6 +908,8 @@ void Translation::_bind_methods() { ClassDB::bind_method(D_METHOD("_set_messages"), &Translation::_set_messages); ClassDB::bind_method(D_METHOD("_get_messages"), &Translation::_get_messages); + BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_message", PropertyInfo(Variant::STRING, "src_message"))); + ADD_PROPERTY(PropertyInfo(Variant::POOL_STRING_ARRAY, "messages", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_messages", "_get_messages"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "locale"), "set_locale", "get_locale"); } diff --git a/doc/classes/Translation.xml b/doc/classes/Translation.xml index 5a7dac9cccf..b9d48f7626f 100644 --- a/doc/classes/Translation.xml +++ b/doc/classes/Translation.xml @@ -11,6 +11,13 @@ https://docs.godotengine.org/en/3.4/tutorials/i18n/locales.html + + + + + Virtual method to override [method get_message]. + +