Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TextServer] Use locale or first span language to select preferred direction for neutral text. #81361

Merged
merged 1 commit into from
Sep 7, 2023

Conversation

bruvzg
Copy link
Member

@bruvzg bruvzg commented Sep 6, 2023

Fixes #81348

@bruvzg bruvzg added this to the 4.2 milestone Sep 6, 2023
@bruvzg bruvzg requested a review from a team as a code owner September 6, 2023 05:50
@akien-mga
Copy link
Member

Actually I need to test a bit, I'm slightly worried that it can lead to unexpected results based on the system locale. E.g. a game meant to be in English / LTR running on an Arabic system, without any special care taken to ensure LTR everywhere. Would this start flipping neutral strings?

@bruvzg
Copy link
Member Author

bruvzg commented Sep 6, 2023

Actually I need to test a bit, I'm slightly worried that it can lead to unexpected results based on the system locale. E.g. a game meant to be in English / LTR running on an Arabic system, without any special care taken to ensure LTR everywhere. Would this start flipping neutral strings?

It should not, get_tool_locale() should only return one of the locales supported by the app (or editor).

String TranslationServer::get_tool_locale() {
#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint() || Engine::get_singleton()->is_project_manager_hint()) {
if (TranslationServer::get_singleton()->get_tool_translation().is_valid()) {
return tool_translation->get_locale();
} else {
return "en";
}
} else {
#else
{
#endif
// Look for best matching loaded translation.
String best_locale = "en";
int best_score = 0;
for (const Ref<Translation> &E : translations) {
const Ref<Translation> &t = E;
ERR_FAIL_COND_V(t.is_null(), best_locale);
String l = t->get_locale();
int score = compare_locales(locale, l);
if (score > 0 && score >= best_score) {
best_locale = l;
best_score = score;
if (score == 10) {
break; // Exact match, skip the rest.
}
}
}
return best_locale;
}
}

@akien-mga akien-mga merged commit 632bbc6 into godotengine:master Sep 7, 2023
16 checks passed
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using only symbols are not RTL when running the project with internationalization/locale/test=ar
2 participants