diff options
author | Thaddeus Crews <repiteo@outlook.com> | 2024-11-21 17:57:01 -0600 |
---|---|---|
committer | Thaddeus Crews <repiteo@outlook.com> | 2024-11-21 17:57:01 -0600 |
commit | f952bfe9985ad8f507cc29b2c7601bbba18b8039 (patch) | |
tree | bc70c21014ebde876f4c06c357ddd248817fa9a7 /core/string | |
parent | 0d8352bd968833e3fde6488ac4ff5210b651645e (diff) | |
parent | 6f4fadf65def83a6a6c885e4aaa11f8982f37916 (diff) | |
download | redot-engine-f952bfe9985ad8f507cc29b2c7601bbba18b8039.tar.gz |
Merge pull request #98972 from dbnicholson/standardize-add-defaults
Expose `TranslationServer::standardize_locale` `add_default` param publicly
Diffstat (limited to 'core/string')
-rw-r--r-- | core/string/translation_server.compat.inc | 41 | ||||
-rw-r--r-- | core/string/translation_server.cpp | 7 | ||||
-rw-r--r-- | core/string/translation_server.h | 8 |
3 files changed, 51 insertions, 5 deletions
diff --git a/core/string/translation_server.compat.inc b/core/string/translation_server.compat.inc new file mode 100644 index 0000000000..11f508c654 --- /dev/null +++ b/core/string/translation_server.compat.inc @@ -0,0 +1,41 @@ +/**************************************************************************/ +/* translation_server.compat.inc */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#ifndef DISABLE_DEPRECATED + +String TranslationServer::_standardize_locale_bind_compat_98972(const String &p_locale) const { + return standardize_locale(p_locale, false); +} + +void TranslationServer::_bind_compatibility_methods() { + ClassDB::bind_compatibility_method(D_METHOD("standardize_locale", "locale"), &TranslationServer::_standardize_locale_bind_compat_98972); +} + +#endif // DISABLE_DEPRECATED diff --git a/core/string/translation_server.cpp b/core/string/translation_server.cpp index 31c221dad7..3d49d482dd 100644 --- a/core/string/translation_server.cpp +++ b/core/string/translation_server.cpp @@ -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); diff --git a/core/string/translation_server.h b/core/string/translation_server.h index bc59c34a38..b6e4bba6e5 100644 --- a/core/string/translation_server.h +++ b/core/string/translation_server.h @@ -52,10 +52,14 @@ class TranslationServer : public Object { static inline TranslationServer *singleton = nullptr; bool _load_translations(const String &p_from); - String _standardize_locale(const String &p_locale, bool p_add_defaults) const; static void _bind_methods(); +#ifndef DISABLE_DEPRECATED + String _standardize_locale_bind_compat_98972(const String &p_locale) const; + static void _bind_compatibility_methods(); +#endif + struct LocaleScriptInfo { String name; String script; @@ -129,7 +133,7 @@ public: void set_pseudolocalization_enabled(bool p_enabled); void reload_pseudolocalization(); - String standardize_locale(const String &p_locale) const; + String standardize_locale(const String &p_locale, bool p_add_defaults = false) const; int compare_locales(const String &p_locale_a, const String &p_locale_b) const; |