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
Support gettext-style language priority list for Minetest's built-in translation system #14428
base: master
Are you sure you want to change the base?
Conversation
This is a feature I support, although in practice I should probably be reviewing other PRs first (like #13687). Any idea how much of a benefit this PR is? I assume a fair amount, as it allows priority lists like |
IMO the ideal solution would be using gettext directly for translation (e.g. by loading translation files using
I chose |
d1e5b24
to
aa3a34f
Compare
5114436
to
bc6e4cc
Compare
611b784
to
e0844bf
Compare
Add compact, short information about your PR for easier understanding:
(GNU?) Gettext allows users to specify a priority list of languages (using the
LANGUAGE
variable) that is applied for translations. This can be seen in the screenshot below (usingenv LANGUAGE=zh_CN:de minetest
).The goal of this PR is to make Minetest's own translation system also support this feature.
I am partly also waiting for #14379 to avoid conflicts.
Note: This PR changes the language code for written Cantonese from
yue_Hant
toyue
. However, considering the (from what I have seen) low translation coverage for this language, I do not think this change will be significant.See title.
Translations
class is extended to also hold language information in the lookup table.Translations
parses the list of languages and looks up the translation for the languages in the list, returning the first one it finds.I can not find a relevant issue.
Partially 2.2 Internal code refactoring.
(The description of 2.3 UI Improvements does not seem to suggests that this PR relates to the stated goal.)
It allows players to specify a list of languages that can be used for translations. In particular, it allows users to specify
zh_CN:zh_TW
orzh_TW:zh_CN
to use the other language variant.To do
This PR is a Work in Progress.
Translations
class to also hold language information.Translations
minetest.get_translated_string
)How to test
unittests
An example with the mail mod can be seen in the following screenshot:
Implementation notes
language_list
. While this does make sense in that the language selector has certain cases that need to be handled in a special way:LANG_CODE
string has been replaced by a language list hardcoded (partly with CMake) into C++ as a relatively ugly macro. I would appreciate it if someone could suggest an alternative approach.LANG_CODE
is translated to (more or less) the same language string, withyue -> yue_Hant
(written Cantonese) being the only exception.core.language_names
only to the mainmenu API as I do not think it makes sense to export it to the regular/async environment when the value can vary between the server and clients.