mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
Expose standardize_locale add_default param publicly
Comparing locales can have surprising outcomes since it standardizes locales with defaults. For example, zh and zh_CN result in an exact match since the defaults change them both to zh_Hans_CN. Expose the add_default parameter publicly with a default of false so the fully standardized locale can be inspected.
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
/**************************************************************************/
|
||||
|
||||
#include "translation_server.h"
|
||||
#include "translation_server.compat.inc"
|
||||
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/io/resource_loader.h"
|
||||
@@ -218,8 +219,8 @@ TranslationServer::Locale::Locale(const TranslationServer &p_server, const Strin
|
||||
}
|
||||
}
|
||||
|
||||
String TranslationServer::standardize_locale(const String &p_locale) const {
|
||||
return Locale(*this, p_locale, false).operator String();
|
||||
String TranslationServer::standardize_locale(const String &p_locale, bool p_add_defaults) const {
|
||||
return Locale(*this, p_locale, p_add_defaults).operator String();
|
||||
}
|
||||
|
||||
int TranslationServer::compare_locales(const String &p_locale_a, const String &p_locale_b) const {
|
||||
@@ -591,7 +592,7 @@ void TranslationServer::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_tool_locale"), &TranslationServer::get_tool_locale);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("compare_locales", "locale_a", "locale_b"), &TranslationServer::compare_locales);
|
||||
ClassDB::bind_method(D_METHOD("standardize_locale", "locale"), &TranslationServer::standardize_locale);
|
||||
ClassDB::bind_method(D_METHOD("standardize_locale", "locale", "add_defaults"), &TranslationServer::standardize_locale, DEFVAL(false));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_all_languages"), &TranslationServer::get_all_languages);
|
||||
ClassDB::bind_method(D_METHOD("get_language_name", "language"), &TranslationServer::get_language_name);
|
||||
|
||||
Reference in New Issue
Block a user