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

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


products:pyrog:api:lastest:types:lang_constant

Различия

Показаны различия между двумя версиями страницы.

Ссылка на это сравнение

products:pyrog:api:lastest:types:lang_constant [2026/05/15 20:49] – создано - внешнее изменение 127.0.0.1products:pyrog:api:lastest:types:lang_constant [2026/08/14 15:25] (текущий) – удалено - внешнее изменение (Дата неизвестна) 127.0.0.1
Строка 1: Строка 1:
-~~NOTOC~~ 
-<WRAP center round info 80%> 
-Текст документации сгенерирован автоматически из [[https://github.com/iron-mesh/Pyrog|исходного кода]].\\ 
-Если обнаружили ошибку, отправьте об этом сообщение на [[feedback@ironmesh.ru|📧почту]]. 
-</WRAP> 
- 
-====== 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 === 
- 
- 
-<code python>def unpack() -> tuple[str, str, str]</code> 
- 
-Returns unpacked Language constant as tuple. 
- 
-**Returns:** 
-  * //tuple%%[%%str, str, str%%]%%// — tuple of Language constant details (context, key, disambiguation) 
- 
- 
-=== translate === 
- 
- 
-<code python>def translate(lang_code: Optional[str] = None) -> None</code> 
- 
-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 === 
- 
- 
-<code python>def get_translation(n: int | float = 1) -> str</code> 
- 
-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 === 
- 
- 
-<code python>def delete_translation()</code> 
- 
-Deletes the translation of language constant. 
- 
- 
-=== __call__ === 
- 
- 
-<code python>def __call__(n: int | float = 1) -> str</code> 
- 
-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__ === 
- 
- 
-<code python>def __str__() -> str</code> 
- 
-Returns the translation of language constant if exists, source text - otherwise. 
- 
-**Returns:** 
-  * //str// — the translation of language constant if exists, source text - otherwise.