-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
gettext.install() ignores previous call to locale.setlocale() #64243
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
Comments
It seems that gettext.install() uses environment variables such as LANGUAGE, to find out which language it should use to find the translation file. This means that any local settings done by setlocale() previoulsy are ignored. I don't think it's the case with the C implementation. |
I tested a small C program and found that setlocale takes precedence for LC_ALL, LC_MESSAGES, and LANG but not for LANGUAGE. int main(int argc, char **argv) {
char *message1;
message1 = gettext("lemon");
printf("%s\n", message1);
return 0;
} $ LC_ALL=es_MX.utf-8 LANGUAGE= LC_MESSAGES=es_MX.utf-8 LANG=es_MX.utf-8 ./test
limão
$ LANGUAGE=es_MX LANG=es_MX.utf-8 ./test
limón So this could be considered a bug in the stdlib's gettext. If we fix it, we'll need to make sure that we continue to honor LANGUAGE, though. |
|
cc @tomasr8 |
I think it makes sense to align our gettext implementation with C, that is, let the result of In any case, this part of gettext has no dedicated tests. I have a patch ready which tests |
Testing will not be too simple, environment variables are not something we can really control. |
I don't think it'll be that bad, we have |
Can I write some tests for find() or do you already have some ready? |
Feel free! I will open a PR for |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
Linked PRs
locale.getlocale
fall back ingettext.find
#131477The text was updated successfully, but these errors were encountered: