Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #27935
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; 'args': 0.04; 'explicitly': 0.04; 'that?': 0.05; 'things.': 0.05; '"__main__":': 0.07; '__name__': 0.07; 'exit': 0.07; 'parser': 0.07; 'utf-8': 0.07; 'python': 0.09; 'gettext': 0.09; 'positional': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'snippet': 0.09; 'translations': 0.09; 'url:github': 0.09; '\xe2\x80\x94': 0.09; 'def': 0.10; 'english.': 0.15; 'properly': 0.15; '--help': 0.16; '--version': 0.16; '-h,': 0.16; '-v,': 0.16; '...,': 0.16; '...]]': 0.16; 'anyways,': 0.16; 'argparse': 0.16; 'arguments:': 0.16; 'fancy': 0.16; 'received:80.91.229.3': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-dialin.net': 0.16; 'subject:argparse': 0.16; 'trash': 0.16; 'wrapped:': 0.16; 'wrote:': 0.17; 'fix': 0.17; 'import': 0.21; 'subject:support': 0.22; 'seems': 0.23; 'header :User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.28; 'cat': 0.29; 'optional': 0.29; 'workaround': 0.29; 'to:addr:python-list': 0.33; 'version': 0.34; 'there': 0.35; 'add': 0.36; 'received:org': 0.36; 'but': 0.36; 'skip:p 20': 0.36; 'option': 0.37; 'subject:: ': 0.38; 'skip:l 20': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'help': 0.40; 'most': 0.61; 'provide': 0.62; 'show': 0.63 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: argparse localization support |
| Date | Sun, 26 Aug 2012 19:21:54 +0200 |
| Organization | None |
| References | <CAMw+j7K39W3xVy7XznB87cnMs6WVvkGcnV_q7mxexnCwEoNTkQ@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="UTF-8" |
| Content-Transfer-Encoding | 8Bit |
| X-Gmane-NNTP-Posting-Host | p50849e85.dip.t-dialin.net |
| User-Agent | KNode/4.7.3 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3845.1346001704.4697.python-list@python.org> (permalink) |
| Lines | 54 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1346001704 news.xs4all.nl 6841 [2001:888:2000:d::a6]:40562 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:27935 |
Show key headers only | View raw
Kwpolska wrote:
> I am using argparse in my project. I want to localize it, but it
> seems to be impossible to change some things. See this, for example:
>
> usage: trash [-h] [-V] [-e] [-l] [-r] [-v] [-w] [PLIK [PLIK ...]]
>
> Trashman — menedżer śmietnika XDG w Pythonie.
>
> positional arguments:
> PLIK pliki do wyrzucenia
>
> optional arguments:
> -h, --help show this help message and exit
> -V, --version show program's version number and exit
>
> (a snippet of help for Trashman, a Python trash manager, with
> LANG='pl_PL.UTF-8'; https://github.com/Kwpolska/trashman )
>
> Anyways, you can see that -h and -V (added semi-automatically by
> argparse), “usage:” and “positional/optional arguments:” are still in
> English. It doesn’t look very professional. Also, I want to use
> fancy UTF-8 characters. Is there a way to fix that?
I don't know much about gettext, but the following suggests that most
strings in argparse are properly wrapped:
$ cat localize_argparse.py
import gettext
def my_gettext(s):
return s.upper()
gettext.gettext = my_gettext
import argparse
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-V", action="version")
args = parser.parse_args()
$ python localize_argparse.py -h
USAGE: localize_argparse.py [-h] [-V]
OPTIONAL ARGUMENTS:
-h, --help SHOW THIS HELP MESSAGE AND EXIT
-V show program's version number and exit
The workaround for the "-V" option would be to add the help message
explicitly
parser.add_argument("-V", ..., help=_("show..."))
You still have to provide all translations yourself.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: argparse localization support Peter Otten <__peter__@web.de> - 2012-08-26 19:21 +0200
csiph-web