summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorKen Paulson <ken@muffinmangames.com>2019-04-24 21:39:29 -0400
committerKen Paulson <ken@muffinmangames.com>2019-04-24 21:39:29 -0400
commit6b117c44fb61db32e6b6ac4da1cf36c7c97c6771 (patch)
treed02c624aeae59bcd5bd81483274dc5c261cc61fd /core
parente9be53acd73f63f8dddc829bb8f34b2afd6c7041 (diff)
Added TranslationServer::get_loaded_locales to return an array of all locales with a loaded Translation
Diffstat (limited to 'core')
-rw-r--r--core/translation.cpp15
-rw-r--r--core/translation.h2
2 files changed, 17 insertions, 0 deletions
diff --git a/core/translation.cpp b/core/translation.cpp
index 6921f1d9f1..afbc639eaa 100644
--- a/core/translation.cpp
+++ b/core/translation.cpp
@@ -968,6 +968,19 @@ String TranslationServer::get_locale_name(const String &p_locale) const {
return locale_name_map[p_locale];
}
+Array TranslationServer::get_loaded_locales() const {
+ Array locales;
+ for (const Set<Ref<Translation> >::Element *E = translations.front(); E; E = E->next()) {
+
+ const Ref<Translation> &t = E->get();
+ String l = t->get_locale();
+
+ locales.push_back(l);
+ }
+
+ return locales;
+}
+
Vector<String> TranslationServer::get_all_locales() {
Vector<String> locales;
@@ -1168,6 +1181,8 @@ void TranslationServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("remove_translation", "translation"), &TranslationServer::remove_translation);
ClassDB::bind_method(D_METHOD("clear"), &TranslationServer::clear);
+
+ ClassDB::bind_method(D_METHOD("get_loaded_locales"), &TranslationServer::get_loaded_locales);
}
void TranslationServer::load_translations() {
diff --git a/core/translation.h b/core/translation.h
index b12bad0d72..d172b9ecf2 100644
--- a/core/translation.h
+++ b/core/translation.h
@@ -94,6 +94,8 @@ public:
String get_locale_name(const String &p_locale) const;
+ Array get_loaded_locales() const;
+
void add_translation(const Ref<Translation> &p_translation);
void remove_translation(const Ref<Translation> &p_translation);