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

gettext.install() ignores previous call to locale.setlocale() #64243

Open
fmoreau mannequin opened this issue Dec 21, 2013 · 2 comments
Open

gettext.install() ignores previous call to locale.setlocale() #64243

fmoreau mannequin opened this issue Dec 21, 2013 · 2 comments
Labels
stdlib Python modules in the Lib dir

Comments

@fmoreau
Copy link
Mannequin

fmoreau mannequin commented Dec 21, 2013

BPO 20044
Nosy @jwilk, @abadger

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:

assignee = None
closed_at = None
created_at = <Date 2013-12-21.16:15:20.607>
labels = ['library']
title = 'gettext.install() ignores previous call to locale.setlocale()'
updated_at = <Date 2019-05-12.14:29:47.179>
user = 'https://bugs.python.org/fmoreau'

bugs.python.org fields:

activity = <Date 2019-05-12.14:29:47.179>
actor = 'a.badger'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2013-12-21.16:15:20.607>
creator = 'fmoreau'
dependencies = []
files = []
hgrepos = []
issue_num = 20044
keywords = []
message_count = 2.0
messages = ['206762', '342258']
nosy_count = 3.0
nosy_names = ['jwilk', 'a.badger', 'fmoreau']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = None
url = 'https://bugs.python.org/issue20044'
versions = ['Python 2.7']

@fmoreau
Copy link
Mannequin Author

fmoreau mannequin commented Dec 21, 2013

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.

@fmoreau fmoreau mannequin added the stdlib Python modules in the Lib dir label Dec 21, 2013
@abadger
Copy link
Mannequin

abadger mannequin commented May 12, 2019

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;
//setlocale (LC_ALL, "");
setlocale (LC_ALL, "pt_BR.utf-8");
bindtextdomain ("testc", "/srv/python/cpython/tmp");
textdomain ("testc");
    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.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
Status: No status
Status: No status
Development

No branches or pull requests

0 participants