summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-02-07 19:38:29 +0100
committerRémi Verschelde <rverschelde@gmail.com>2023-02-07 19:38:29 +0100
commita05670c617abc1df93ebac5afacf3e6c48008a99 (patch)
tree511589355c48e409b318c40a9658b5d6de262c9a /core
parentbd267c911b765b0f2290c744a0ca0d8e72806f58 (diff)
parent097cf5431bc2895906047cdabc772919ab5e7bee (diff)
Merge pull request #70623 from timothyqiu/property-i18n
Separate property translation from editor translation, move sources to separate godot-editor-l10n repo
Diffstat (limited to 'core')
-rw-r--r--core/string/translation.cpp14
-rw-r--r--core/string/translation.h3
2 files changed, 17 insertions, 0 deletions
diff --git a/core/string/translation.cpp b/core/string/translation.cpp
index 60dca8ebc6..b9d5d3b538 100644
--- a/core/string/translation.cpp
+++ b/core/string/translation.cpp
@@ -768,6 +768,20 @@ StringName TranslationServer::doc_translate_plural(const StringName &p_message,
return p_message_plural;
}
+void TranslationServer::set_property_translation(const Ref<Translation> &p_translation) {
+ property_translation = p_translation;
+}
+
+StringName TranslationServer::property_translate(const StringName &p_message) const {
+ if (property_translation.is_valid()) {
+ StringName r = property_translation->get_message(p_message);
+ if (r) {
+ return r;
+ }
+ }
+ return p_message;
+}
+
bool TranslationServer::is_pseudolocalization_enabled() const {
return pseudolocalization_enabled;
}
diff --git a/core/string/translation.h b/core/string/translation.h
index 8646635eb8..01d239f81c 100644
--- a/core/string/translation.h
+++ b/core/string/translation.h
@@ -78,6 +78,7 @@ class TranslationServer : public Object {
HashSet<Ref<Translation>> translations;
Ref<Translation> tool_translation;
Ref<Translation> doc_translation;
+ Ref<Translation> property_translation;
bool enabled = true;
@@ -174,6 +175,8 @@ public:
void set_doc_translation(const Ref<Translation> &p_translation);
StringName doc_translate(const StringName &p_message, const StringName &p_context = "") const;
StringName doc_translate_plural(const StringName &p_message, const StringName &p_message_plural, int p_n, const StringName &p_context = "") const;
+ void set_property_translation(const Ref<Translation> &p_translation);
+ StringName property_translate(const StringName &p_message) const;
void setup();