manpagez: man pages & more
info gettext
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

15.5.4 Python

RPMs

python

File extension

py

String syntax

'abc', u'abc', r'abc', ur'abc',
"abc", u"abc", r"abc", ur"abc",
'''abc''', u'''abc''', r'''abc''', ur'''abc''',
"""abc""", u"""abc""", r"""abc""", ur"""abc"""

gettext shorthand

_('abc') etc.

gettext/ngettext functions

gettext.gettext, gettext.dgettext, gettext.ngettext, gettext.dngettext, also ugettext, ungettext

textdomain

gettext.textdomain function, or gettext.install(domain) function

bindtextdomain

gettext.bindtextdomain function, or gettext.install(domain,localedir) function

setlocale

not used by the gettext emulation

Prerequisite

import gettext

Use or emulate GNU gettext

emulate

Extractor

xgettext

Formatting with positions

'...%(ident)d...' % { 'ident': value }

Portability

fully portable

po-mode marking

An example is available in the ‘examples’ directory: hello-python.

A note about format strings: Python supports format strings with unnamed arguments, such as '...%d...', and format strings with named arguments, such as '...%(ident)d...'. The latter are preferable for internationalized programs, for two reasons:


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on June 7, 2014 using texi2html 5.0.

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.