From 6b117c44fb61db32e6b6ac4da1cf36c7c97c6771 Mon Sep 17 00:00:00 2001 From: Ken Paulson Date: Wed, 24 Apr 2019 21:39:29 -0400 Subject: [PATCH] Added TranslationServer::get_loaded_locales to return an array of all locales with a loaded Translation --- core/translation.cpp | 15 +++++++++++++++ core/translation.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/core/translation.cpp b/core/translation.cpp index 6921f1d9f1b..afbc639eaa6 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 >::Element *E = translations.front(); E; E = E->next()) { + + const Ref &t = E->get(); + String l = t->get_locale(); + + locales.push_back(l); + } + + return locales; +} + Vector TranslationServer::get_all_locales() { Vector 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 b12bad0d727..d172b9ecf2e 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 &p_translation); void remove_translation(const Ref &p_translation);