[issue39464] Allow translating argparse error messages

hai shi report at bugs.python.org
Sat Feb 1 03:20:45 EST 2020


hai shi <shihai1991 at 126.com> added the comment:

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 ./drt.py -l
Uso: ./drt.py [-h] [-l LONG_MIN] [-L LONG_MAX] [-v] [-V]
               entrada.json [salida.tok]
./drt.py: 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:

`./drt.py: error: parámetro -l/--min-length: se esperaba un parámetro`

----------
nosy: +shihai1991

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39464>
_______________________________________


More information about the Python-bugs-list mailing list