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

Translation: Use proper language code for locale near matching, including in ResourceLoader #34103

Conversation

akien-mga
Copy link
Member

@akien-mga akien-mga commented Dec 4, 2019

  • Translation: Refactor locale matching to use proper language code
    0fcb68f

The previous code only parsed the first two characters (potentially reading
out of bounds if input was invalid), but some locales use a 3-letter language
code (e.g. 'nah_MX').

So I refactored the logic a bit to properly parse the locale and extract the
part left of the regional code, if provided (supports both 'en_US' and 'en-US'
style).

I made TranslationServer::get_language_code() public as I'll use it in a
follow up commit.


  • ResourceLoader: Add language code matching for localized resources
    95242b7

Near matching was not implemented like in TranslationServer, so a
resource remapped for 'ru' (but not 'ru_RU') would not be used as
fallback if the system locale was 'ru_RU'.

Fixes #34058.


CC @DrMoriarty

One thing which I haven't implemented in ResourceLoader is the actual locale/fallback manual fallback locale that can be used in Translation. It might be worth doing eventually.

The previous code only parsed the first two characters (potentially reading
out of bounds if input was invalid), but some locales use a 3-letter language
code (e.g. 'nah_MX').

So I refactored the logic a bit to properly parse the locale and extract the
part left of the regional code, if provided (supports both 'en_US' and 'en-US'
style).

I made TranslationServer::get_language_code() public as I'll use it in a
follow up commit.
Near matching was not implemented like in TranslationServer, so a
resource remapped for 'ru' (but not 'ru_RU') would not be used as
fallback if the system locale was 'ru_RU'.

Fixes godotengine#34058.
@akien-mga akien-mga added this to the 3.2 milestone Dec 4, 2019
@akien-mga akien-mga merged commit fe21449 into godotengine:master Dec 5, 2019
@akien-mga akien-mga deleted the resourceloader-remap-locale-near-matching branch December 5, 2019 05:50
@YeldhamDev
Copy link
Member

Could you also make get_language_code() available for scripting?

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.

Bug in localized remapped resources
2 participants