From 6b117c44fb61db32e6b6ac4da1cf36c7c97c6771 Mon Sep 17 00:00:00 2001
From: Ken Paulson <ken@muffinmangames.com>
Date: Wed, 24 Apr 2019 21:39:29 -0400
Subject: 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(+)

(limited to 'core')

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);
 
-- 
cgit v1.2.3