Files
odoo-stubs/odoo-stubs/tools/translate.pyi
Trinh Anh Ngoc 6144774401 Update stubs
2022-10-10 17:08:30 +07:00

146 lines
5.8 KiB
Python

import csv
from collections import namedtuple
from re import Match, Pattern
from tarfile import TarFile
from types import FrameType
from typing import Any, BinaryIO, Callable, Container, IO, Iterable, Iterator, NoReturn
from lxml.etree import HTMLParser, _Element
from polib import POFile
from .pycompat import _CsvWriter
from ..api import Environment
from ..models import BaseModel
from ..sql_db import Connection, Cursor
WEB_TRANSLATION_COMMENT: str
SKIPPED_ELEMENTS: tuple[str, ...]
_LOCALE2WIN32: dict[str, str]
ENGLISH_SMALL_WORDS: set[str]
class UNIX_LINE_TERMINATOR(csv.excel):
lineterminator: str
def encode(s: str) -> str: ...
TRANSLATED_ELEMENTS: set[str]
TRANSLATED_ATTRS: dict[str, Any]
def translate_attrib_value(node: _Element) -> bool: ...
avoid_pattern: Pattern
node_pattern: Pattern
def translate_xml_node(node: _Element, callback: Callable[[str], str | None], parse: Callable[[str], _Element],
serialize: Callable[[_Element], str]) -> _Element: ...
def parse_xml(text: str) -> _Element: ...
def serialize_xml(node: _Element) -> str: ...
_HTML_PARSER: HTMLParser
def parse_html(text: str) -> _Element: ...
def serialize_html(node: _Element) -> str: ...
def xml_translate(callback: Callable[[str], str | None], value: str) -> str: ...
def html_translate(callback: Callable[[str], str | None], value: str) -> str: ...
def translate(cr: Cursor, name: str, source_type: str, lang: str, source: str | None = ...) -> str: ...
def translate_sql_constraint(cr: Cursor, key: str, lang: str) -> str: ...
class GettextAlias:
def _get_db(self) -> Connection | None: ...
def _get_cr(self, frame: FrameType, allow_create: bool = ...) -> tuple[Cursor, bool]: ...
def _get_uid(self, frame: FrameType) -> int: ...
def _get_lang(self, frame: FrameType) -> str: ...
def __call__(self, source: str, *args, **kwargs) -> str: ...
def _get_translation(self, source: str) -> str: ...
class _lt:
__slots__ = ['_source', '_args']
_source: str
_args: tuple
def __init__(self, source: str, *args, **kwargs) -> None: ...
def __str__(self) -> str: ...
def __eq__(self, other) -> NoReturn: ...
def __lt__(self, other) -> NoReturn: ...
def __add__(self, other: str | _lt) -> str: ...
def __radd__(self, other: str) -> str: ...
_: GettextAlias
def quote(s: str) -> str: ...
re_escaped_char: Pattern
re_escaped_replacements: dict[str, str]
def _sub_replacement(match_obj: Match) -> str: ...
def unquote(str: str) -> str: ...
def TranslationFileReader(source: IO, fileformat: str = ...) -> CSVFileReader | PoFileReader: ...
class CSVFileReader:
source: csv.DictReader
prev_code_src: str
def __init__(self, source: IO) -> None: ...
def __iter__(self) -> Iterator[csv.DictReader]: ...
class PoFileReader:
pofile: POFile
def __init__(self, source: str | IO): ...
def __iter__(self) -> Iterator[dict[str, Any]]: ...
def TranslationFileWriter(target, fileformat: str = ..., lang: str | None = ...) -> CSVFileWriter | PoFileWriter | TarFileWriter: ...
class CSVFileWriter:
writer: _CsvWriter
def __init__(self, target: BinaryIO) -> None: ...
def write_rows(self, rows: Iterable) -> None: ...
class PoFileWriter:
buffer: IO
lang: str
po: POFile
def __init__(self, target: IO, lang: str) -> None: ...
def write_rows(self, rows: Iterable) -> None: ...
def add_entry(self, modules, tnrs, source, trad, comments: Iterable[str] | None = ...) -> None: ...
class TarFileWriter:
tar: TarFile
lang: str
def __init__(self, target: IO, lang: str) -> None: ...
def write_rows(self, rows: Iterable) -> None: ...
def trans_export(lang: str, modules: list[str], buffer, format: str, cr: Cursor) -> None: ...
def trans_parse_rml(de: Iterable) -> list[bytes]: ...
def _push(callback: Callable[[str, int], Any], term: str, source_line: int) -> None: ...
def in_modules(object_name: str, modules: Container[str]) -> bool: ...
def _extract_translatable_qweb_terms(element: _Element, callback: Callable[[str, int], Any]) -> None: ...
def babel_extract_qweb(fileobj: IO, keywords, comment_tags, options) -> list[tuple]: ...
ImdInfo = namedtuple('ExternalId', ['name', 'model', 'res_id', 'module'])
class TranslationModuleReader:
_cr: Cursor
_modules: list[str]
_lang: str | None
env: Environment
_to_translate: list[tuple]
_path_list: list[tuple[str, Any]]
_installed_modules: list[str]
def __init__(self, cr: Cursor, modules: list[str] | None = ..., lang: str | None = ...) -> None: ...
def __iter__(self) -> Iterable[tuple]: ...
def _push_translation(self, module: str, ttype: str, name: str, res_id: str, source: str,
comments: Iterable[str] | None = ..., record_id: int | None = ...) -> None: ...
def _get_translatable_records(self, imd_records: Iterable[ImdInfo]) -> BaseModel: ...
def _export_translatable_records(self) -> None: ...
def _get_module_from_path(self, path: str) -> str: ...
def _verified_module_filepaths(self, fname: str, path: str, root: str) -> tuple[str | None, str | None, str | None, str | None]: ...
def _babel_extract_terms(self, fname: str, path: str, root: str, extract_method: str = ..., trans_type: str = ...,
extra_comments: list[str] | None = ..., extract_keywords: dict = ...) -> None: ...
def _export_translatable_resources(self) -> None: ...
def trans_load(cr: Cursor, filename: str, lang: str, verbose: bool = ..., create_empty_translation: bool = ...,
overwrite: bool = ...) -> None: ...
def trans_load_data(cr: Cursor, fileobj: IO, fileformat: str, lang: str, verbose: bool = ...,
create_empty_translation: bool = ..., overwrite: bool = ...) -> None: ...
def get_locales(lang: str | None = ...) -> None: ...
def resetlocale() -> str: ...
def load_language(cr: Cursor, lang: str) -> None: ...