Инструменты пользователя

Инструменты сайта


products:pyrog:api:lastest:types:lang_constant

Текст документации сгенерирован автоматически из исходного кода.
Если обнаружили ошибку, отправьте об этом сообщение на 📧почту.

LangConstant

Creates a language constant. Keeps original text and it's translations. Use it to have access to translations without loaded dictionaries at any time.

Attributes:

  • context: str — The context of the language constant.
  • key: str — a source text of the language constant.
  • disambiguation: str — an identifying string, for when the same [key] is used in different roles within the same context.

Methods

unpack

def unpack() -> tuple[str, str, str]

Returns unpacked Language constant as tuple.

Returns:

  • tuple[str, str, str] — tuple of Language constant details (context, key, disambiguation)

translate

def translate(lang_code: Optional[str] = None) -> None

Translates the language constant.

Optionally accept language code to extract translations for plural forms. Attention: doesn't support all languages, Russian and English only.

Parameters:

  • lang_code: Optional[str] — language code, for example 'en' or 'en_GB (info about territory is ignored)'.

Returns:

  • None — (without description)

Raises:

  • TypeError — if arg <lang_code> is not a string.

get_translation

def get_translation(n: int | float = 1) -> str

Returns the translation of language constant if exists, source text - otherwise.

Parameters:

  • n: int | float — a numeral for determining the plural form.

Returns:

  • str — the translation of language constant if exists, source text - otherwise.

delete_translation

def delete_translation()

Deletes the translation of language constant.

__call__

def __call__(n: int | float = 1) -> str

Returns the translation of language constant if exists, source text - otherwise.

Parameters:

  • n: int | float — a numeral for determining the plural form.

Returns:

  • str — the translation of language constant if exists, source text - otherwise.

__str__

def __str__() -> str

Returns the translation of language constant if exists, source text - otherwise.

Returns:

  • str — the translation of language constant if exists, source text - otherwise.
products/pyrog/api/lastest/types/lang_constant.txt · Последнее изменение: 127.0.0.1