Title: Allow translating argparse error messages
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.9
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: DjMorgul, paul.j3, rhettinger, shihai1991
Priority: normal Keywords:

Created on 2020-01-27 13:55 by DjMorgul, last changed 2020-02-01 08:37 by shihai1991.

Pull Requests
URL Status Linked Edit
PR 17169 open DjMorgul, 2020-01-27 13:55
Messages (3)
msg360764 - (view) Author: José Manuel Ferrer (DjMorgul) * Date: 2020-01-27 13:55
Argument error messages display the untranslatable text 'argument ', which should be translatable to other languages, just like it's possible to do with the rest of the constructed error message.
msg361156 - (view) Author: Hai Shi (shihai1991) * (Python triager) Date: 2020-02-01 08:20
Paste José's comment from PR17169:

This message isn't used (only?) in exceptions... it's a message that is given to the console, to notify the user when she didn't provide correct parameters. For example:
$ python3 ./ -l
Uso: ./ [-h] [-l LONG_MIN] [-L LONG_MAX] [-v] [-V]
               entrada.json [salida.tok]
./ error: argument -l/--min-length: se esperaba un parámetro

These are console messages localized into Spanish. The "error:" part is translatable, but it's the same word in Spanish than in English. The "argument" part is what isn't translatable, and it's taken from this "exception".

I confirmed that my proposed patch, translating that particular string, allows giving a fully localized console output to the user in Spanish, such as:

`./ error: parámetro -l/--min-length: se esperaba un parámetro`
msg361157 - (view) Author: Hai Shi (shihai1991) * (Python triager) Date: 2020-02-01 08:37
Users interact with console's output, so translated the output info is fine to me.
Hi,raymond、paul. What's your opinion?
Date User Action Args
2020-02-01 08:37:32shihai1991setmessages: + msg361157
2020-02-01 08:20:45shihai1991setnosy: + shihai1991
messages: + msg361156
2020-01-27 14:29:44xtreaksettitle: Allow translating argument error messages -> Allow translating argparse error messages
2020-01-27 14:29:25xtreaksetnosy: + rhettinger, paul.j3

versions: - Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8
2020-01-27 13:55:37DjMorgulcreate