Implement override of get_message
This commit is contained in:
parent
047108a4ca
commit
cddabf2a8b
|
@ -871,6 +871,10 @@ void Translation::add_message(const StringName &p_src_text, const StringName &p_
|
||||||
translation_map[p_src_text] = p_xlated_text;
|
translation_map[p_src_text] = p_xlated_text;
|
||||||
}
|
}
|
||||||
StringName Translation::get_message(const StringName &p_src_text) const {
|
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<StringName, StringName>::Element *E = translation_map.find(p_src_text);
|
const Map<StringName, StringName>::Element *E = translation_map.find(p_src_text);
|
||||||
if (!E) {
|
if (!E) {
|
||||||
return StringName();
|
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("_set_messages"), &Translation::_set_messages);
|
||||||
ClassDB::bind_method(D_METHOD("_get_messages"), &Translation::_get_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::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");
|
ADD_PROPERTY(PropertyInfo(Variant::STRING, "locale"), "set_locale", "get_locale");
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,13 @@
|
||||||
<link>https://docs.godotengine.org/en/3.4/tutorials/i18n/locales.html</link>
|
<link>https://docs.godotengine.org/en/3.4/tutorials/i18n/locales.html</link>
|
||||||
</tutorials>
|
</tutorials>
|
||||||
<methods>
|
<methods>
|
||||||
|
<method name="_get_message" qualifiers="virtual">
|
||||||
|
<return type="String" />
|
||||||
|
<argument index="0" name="src_message" type="String" />
|
||||||
|
<description>
|
||||||
|
Virtual method to override [method get_message].
|
||||||
|
</description>
|
||||||
|
</method>
|
||||||
<method name="add_message">
|
<method name="add_message">
|
||||||
<return type="void" />
|
<return type="void" />
|
||||||
<argument index="0" name="src_message" type="String" />
|
<argument index="0" name="src_message" type="String" />
|
||||||
|
|
Loading…
Reference in New Issue