mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 04:34:28 +08:00
Add stubs for translationstring (#9918)
This commit is contained in:
14
stubs/translationstring/@tests/stubtest_allowlist.txt
Normal file
14
stubs/translationstring/@tests/stubtest_allowlist.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
# Error: is not present in stub
|
||||
# =============================
|
||||
# string patterns for internal use that should not be exported
|
||||
translationstring.CONTEXT_MASK
|
||||
translationstring.NAME_RE
|
||||
|
||||
|
||||
# Error: failed to find stubs
|
||||
# ===========================
|
||||
# PY2 compat stuff that is not needed externally
|
||||
translationstring.compat
|
||||
|
||||
# tests that should not be part of the distribution anyway
|
||||
translationstring.tests.*
|
||||
1
stubs/translationstring/METADATA.toml
Normal file
1
stubs/translationstring/METADATA.toml
Normal file
@@ -0,0 +1 @@
|
||||
version = "1.4.*"
|
||||
81
stubs/translationstring/translationstring/__init__.pyi
Normal file
81
stubs/translationstring/translationstring/__init__.pyi
Normal file
@@ -0,0 +1,81 @@
|
||||
from collections.abc import Callable
|
||||
from gettext import NullTranslations
|
||||
from typing import Any, Protocol
|
||||
from typing_extensions import Self
|
||||
|
||||
class _TranslationStringFactory(Protocol):
|
||||
def __call__(
|
||||
self,
|
||||
msgid: str | TranslationString,
|
||||
mapping: dict[str, Any] | None = ...,
|
||||
default: str | None = ...,
|
||||
context: str | None = ...,
|
||||
) -> TranslationString: ...
|
||||
|
||||
class _ChameleonTranslate(Protocol):
|
||||
def __call__(
|
||||
self,
|
||||
msgid: str | TranslationString,
|
||||
mapping: dict[str, Any] | None = ...,
|
||||
context: str | None = ...,
|
||||
target_language: str | None = ...,
|
||||
default: str | None = ...,
|
||||
) -> TranslationString: ...
|
||||
|
||||
class _TranslatorPolicy(Protocol):
|
||||
def __call__(self, translations: NullTranslations, tstring: str, domain: str | None, context: str | None) -> str: ...
|
||||
|
||||
class _Translator(Protocol):
|
||||
def __call__(
|
||||
self,
|
||||
tstring: str | TranslationString,
|
||||
domain: str | None = None,
|
||||
mapping: dict[str, Any] | None = None,
|
||||
context: str | None = None,
|
||||
) -> str: ...
|
||||
|
||||
class _PluralizerPolicy(Protocol):
|
||||
def __call__(
|
||||
self, translations: NullTranslations, singular: str, plural: str, n: int, domain: str | None, context: str | None
|
||||
) -> str: ...
|
||||
|
||||
class _Pluralizer(Protocol):
|
||||
def __call__(
|
||||
self,
|
||||
singular: str | TranslationString,
|
||||
plural: str | TranslationString,
|
||||
n: int,
|
||||
domain: str | None = None,
|
||||
mapping: dict[str, Any] | None = None,
|
||||
context: str | None = None,
|
||||
) -> str: ...
|
||||
|
||||
class TranslationString(str):
|
||||
domain: str | None
|
||||
context: str | None
|
||||
default: str
|
||||
mapping: dict[str, Any] | None
|
||||
def __new__(
|
||||
self,
|
||||
msgid: str | Self,
|
||||
domain: str | None = None,
|
||||
default: str | None = None,
|
||||
mapping: dict[str, Any] | None = None,
|
||||
context: str | None = None,
|
||||
) -> Self: ...
|
||||
def __mod__(self, options: dict[str, Any]) -> TranslationString: ... # type:ignore[override]
|
||||
def interpolate(self, translated: str | None = None) -> str: ...
|
||||
def __reduce__(self) -> tuple[type[Self], tuple[str, str | None, str, dict[str, Any], str | None]]: ...
|
||||
|
||||
def TranslationStringFactory(factory_domain: str) -> _TranslationStringFactory: ...
|
||||
def ChameleonTranslate(translator: Callable[[TranslationString], str] | None) -> _ChameleonTranslate: ...
|
||||
def ugettext_policy(translations: NullTranslations, tstring: str, domain: str | None, context: str | None) -> str: ...
|
||||
def dugettext_policy(translations: NullTranslations, tstring: str, domain: str | None, context: str | None) -> str: ...
|
||||
def Translator(translations: NullTranslations | None = None, policy: _TranslatorPolicy | None = None) -> _Translator: ...
|
||||
def ungettext_policy(
|
||||
translations: NullTranslations, singular: str, plural: str, n: int, domain: str | None, context: str | None
|
||||
) -> str: ...
|
||||
def dungettext_policy(
|
||||
translations: NullTranslations, singular: str, plural: str, n: int, domain: str | None, context: str | None
|
||||
) -> str: ...
|
||||
def Pluralizer(translations: NullTranslations | None = None, policy: _PluralizerPolicy | None = None) -> _Pluralizer: ...
|
||||
Reference in New Issue
Block a user