A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-April/063500.html below:

[Python-Dev] The "i" string-prefix: I18n'ed strings

[Python-Dev] The "i" string-prefix: I18n'ed strings"Martin v. Löwis" martin at v.loewis.de
Fri Apr 7 00:16:49 CEST 2006
Martin Blais wrote:
>    ...
>    A(P(_("Click here to forget"), href="...
>    ...

I assume that this should be

  P(A(_("Click here to forget"), href="...

instead (i.e. href is a parameter to A, not to P)

> 
> (In my example, I built a library not unlike stan for creating HTML,
> which is where classes A and P come from.)  I find the i18n markup a
> bit annoying, especially when there are many i18n strings close
> together.  My point is: adding parentheses around almost all strings
> gets tiresome and "charges" the otherwise divine esthetics of Python
> source code.

There is a simple solution to that: write it as

P(a("Click here to forget", href="...

and define

def a(content, **kw):
    return A(_(content), **kw)

You could it also write as

P(A_("Click here to forget", href="...

to make it a little more obvious to the reader that there is a
gettext lookup here.

Regards,
Martin
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4