Merge pull request #112415 from timothyqiu/project-name-localized

Allow localizing the application name with project translations
This commit is contained in:
Thaddeus Crews 2025-11-10 08:20:00 -06:00
commit 9ac55bcc7f
No known key found for this signature in database
GPG key ID: 8C6E5FEB5FC03CCC
12 changed files with 100 additions and 57 deletions

View file

@ -1633,7 +1633,7 @@ ProjectSettings::ProjectSettings() {
#endif
GLOBAL_DEF_BASIC("application/config/name", "");
GLOBAL_DEF_BASIC(PropertyInfo(Variant::DICTIONARY, "application/config/name_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary());
GLOBAL_DEF(PropertyInfo(Variant::DICTIONARY, "application/config/name_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary());
GLOBAL_DEF_BASIC(PropertyInfo(Variant::STRING, "application/config/description", PROPERTY_HINT_MULTILINE_TEXT), "");
GLOBAL_DEF_BASIC("application/config/version", "");
GLOBAL_DEF_INTERNAL(PropertyInfo(Variant::STRING, "application/config/tags"), PackedStringArray());

View file

@ -611,7 +611,10 @@ void TranslationServer::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::Type::BOOL, "pseudolocalization_enabled"), "set_pseudolocalization_enabled", "is_pseudolocalization_enabled");
}
void TranslationServer::load_translations() {
void TranslationServer::load_project_translations(Ref<TranslationDomain> p_domain) {
DEV_ASSERT(p_domain.is_valid());
p_domain->clear();
const String prop = "internationalization/locale/translations";
if (!ProjectSettings::get_singleton()->has_setting(prop)) {
return;
@ -620,7 +623,7 @@ void TranslationServer::load_translations() {
for (const String &path : translations) {
Ref<Translation> tr = ResourceLoader::load(path);
if (tr.is_valid()) {
add_translation(tr);
p_domain->add_translation(tr);
}
}
}

View file

@ -151,7 +151,7 @@ public:
void clear();
void load_translations();
void load_project_translations(Ref<TranslationDomain> p_domain);
#ifdef TOOLS_ENABLED
virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;