Files
typeshed/stdlib/2/gettext.pyi
Philipp Hahn 7c3edba6ce python2/gettext improvements (#2235)
* py2: gettext: info()

returns a Dict[str, str]

<https://docs.python.org/2/library/gettext.html#gettext.NullTranslations.info>
> Return the “protected” _info variable.

<https://docs.python.org/2/library/gettext.html#the-gnutranslations-class>
> The entire set of key/value pairs are placed into a dictionary and set
> as the “protected” _info instance variable.

* py2: gettext: charset()

returns an Optional[str]

<https://docs.python.org/2/library/gettext.html#gettext.NullTranslations.charset>
> Return the “protected” _charset variable.

<https://docs.python.org/2/library/gettext.html#the-gnutranslations-class>
> If the key Content-Type is found, then the charset property is used to
> initialize the “protected” _charset instance variable, defaulting to
> None if not found.

* py2: gettext: [set_]output_charset()

allows to set an Optional[str]

<https://docs.python.org/2/library/gettext.html#gettext.NullTranslations.output_charset>
> Return the “protected” _output_charset variable.

<https://docs.python.org/2/library/gettext.html#gettext.NullTranslations.set_output_charset>
> Change the “protected” _output_charset variable, which defines the
> encoding used to return translated messages.

<https://docs.python.org/2/library/gettext.html#gettext.GNUTranslations.lgettext>
> Equivalent to gettext(), but the translation is returned in the
> preferred system encoding, if no other encoding was explicitly set with
> set_output_charset().

* py2: gettext: install(..., names)

allows to set an Optional[str]

<https://docs.python.org/2/library/gettext.html#gettext.NullTranslations.install>
> If the names parameter is given, it must be a sequence containing the
> names of functions you want to install in the builtins namespace in
> addition to _().

* py2: gettext: localdir=None

is Optional[str]

<https://docs.python.org/2/library/gettext.html#gettext.bindtextdomain>
> If localedir is omitted or None, then the current binding for domain
> is returned.

* py2: gettext: languages=None

is Optional[Sequence[str]]

<https://docs.python.org/2/library/gettext.html#gettext.find>
> If languages is not given, then the following environment variables
> are searched: ...

* py2: gettext: codeset=None

is Optional[str]

<https://docs.python.org/2/library/gettext.html#gettext.translation>
> If provided, codeset will change the charset used to encode translated
> strings.

* py2: gettext: translation(class_=None)

is Optional[type]

<https://docs.python.org/2/library/gettext.html#gettext.translation>
> The actual class instantiated is either class_ if provided, otherwise
> GNUTranslations.

* py2: gettext: translation(fallback)

is bool

<https://docs.python.org/2/library/gettext.html#gettext.translation>
> ..., this function raises IOError if fallback is false (which is the
> default), and returns a NullTranslations instance if fallback is true.

* py2: gettext: install(unicode)

is bool

<https://docs.python.org/2/library/gettext.html#gettext.install>
> The unicode flag is passed to the resulting translation object’s
> install() method.

which is already expecting `bool`.
2018-06-16 10:19:24 -07:00

42 lines
2.3 KiB
Python

from typing import Any, Container, Dict, IO, List, Optional, Sequence, Type, Union
def bindtextdomain(domain: str, localedir: str = ...) -> str: ...
def bind_textdomain_codeset(domain: str, codeset: str = ...) -> str: ...
def textdomain(domain: str = ...) -> str: ...
def gettext(message: str) -> str: ...
def lgettext(message: str) -> str: ...
def dgettext(domain: str, message: str) -> str: ...
def ldgettext(domain: str, message: str) -> str: ...
def ngettext(singular: str, plural: str, n: int) -> str: ...
def lngettext(singular: str, plural: str, n: int) -> str: ...
def dngettext(domain: str, singular: str, plural: str, n: int) -> str: ...
def ldngettext(domain: str, singular: str, plural: str, n: int) -> str: ...
class NullTranslations(object):
def __init__(self, fp: IO[str] = ...) -> None: ...
def _parse(self, fp: IO[str]) -> None: ...
def add_fallback(self, fallback: NullTranslations) -> None: ...
def gettext(self, message: str) -> str: ...
def lgettext(self, message: str) -> str: ...
def ugettext(self, message: Union[str, unicode]) -> unicode: ...
def ngettext(self, singular: str, plural: str, n: int) -> str: ...
def lngettext(self, singular: str, plural: str, n: int) -> str: ...
def ungettext(self, singular: Union[str, unicode], plural: Union[str, unicode], n: int) -> unicode: ...
def info(self) -> Dict[str, str]: ...
def charset(self) -> Optional[str]: ...
def output_charset(self) -> Optional[str]: ...
def set_output_charset(self, charset: Optional[str]) -> None: ...
def install(self, unicode: bool = ..., names: Container[str] = ...) -> None: ...
class GNUTranslations(NullTranslations):
LE_MAGIC = ... # type: int
BE_MAGIC = ... # type: int
def find(domain: str, localedir: Optional[str] = ..., languages: Optional[Sequence[str]] = ...,
all: Any = ...) -> Optional[Union[str, List[str]]]: ...
def translation(domain: str, localedir: Optional[str] = ..., languages: Optional[Sequence[str]] = ...,
class_: Optional[Type[NullTranslations]] = ..., fallback: bool = ..., codeset: Optional[str] = ...) -> NullTranslations: ...
def install(domain: str, localedir: Optional[str] = ..., unicode: bool = ..., codeset: Optional[str] = ...,
names: Container[str] = ...) -> None: ...