diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-01-18 15:43:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-18 15:43:04 +0100 |
commit | ce2b5bdfa893f339078b7d2179b2541dcc71dca1 (patch) | |
tree | 54220f27ad3237e0dee00ec4ae6d8ee0c9dc7339 /core/string/translation.h | |
parent | 28cd81c581365d15ee2cc497d48164de498a7208 (diff) | |
parent | 40c56ed410e828d2062de7e4ba5617b3e1c0f631 (diff) |
Merge pull request #52969 from bruvzg/locale_detection
Diffstat (limited to 'core/string/translation.h')
-rw-r--r-- | core/string/translation.h | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/core/string/translation.h b/core/string/translation.h index e95d15e2ab..947ca4c6d8 100644 --- a/core/string/translation.h +++ b/core/string/translation.h @@ -78,8 +78,6 @@ class TranslationServer : public Object { Ref<Translation> tool_translation; Ref<Translation> doc_translation; - Map<String, String> locale_name_map; - bool enabled = true; bool pseudolocalization_enabled = false; @@ -109,6 +107,23 @@ class TranslationServer : public Object { static void _bind_methods(); + struct LocaleScriptInfo { + String name; + String script; + String default_country; + Set<String> supported_countries; + }; + static Vector<LocaleScriptInfo> locale_script_info; + + static Map<String, String> language_map; + static Map<String, String> script_map; + static Map<String, String> locale_rename_map; + static Map<String, String> country_name_map; + static Map<String, String> country_rename_map; + static Map<String, String> variant_map; + + void init_locale_info(); + public: _FORCE_INLINE_ static TranslationServer *get_singleton() { return singleton; } @@ -119,6 +134,15 @@ public: String get_locale() const; Ref<Translation> get_translation_object(const String &p_locale); + Vector<String> get_all_languages() const; + String get_language_name(const String &p_language) const; + + Vector<String> get_all_scripts() const; + String get_script_name(const String &p_script) const; + + Vector<String> get_all_countries() const; + String get_country_name(const String &p_country) const; + String get_locale_name(const String &p_locale) const; Array get_loaded_locales() const; @@ -136,11 +160,9 @@ public: void set_editor_pseudolocalization(bool p_enabled); void reload_pseudolocalization(); - static Vector<String> get_all_locales(); - static Vector<String> get_all_locale_names(); - static bool is_locale_valid(const String &p_locale); - static String standardize_locale(const String &p_locale); - static String get_language_code(const String &p_locale); + String standardize_locale(const String &p_locale) const; + + int compare_locales(const String &p_locale_a, const String &p_locale_b) const; String get_tool_locale(); void set_tool_translation(const Ref<Translation> &p_translation); |