mirror of
https://github.com/bringout/oca-ocb-core.git
synced 2026-04-22 06:12:07 +02:00
19.0 vanilla
This commit is contained in:
parent
0a7ae8db93
commit
991d2234ca
416 changed files with 646602 additions and 300844 deletions
|
|
@ -1,13 +1,14 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from typing import TYPE_CHECKING, Literal, Optional, Sequence
|
||||
from typing import TYPE_CHECKING, Literal
|
||||
|
||||
from babel import lists
|
||||
|
||||
from odoo.tools.misc import babel_locale_parse, get_lang
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Iterable
|
||||
import odoo.api
|
||||
|
||||
XPG_LOCALE_RE = re.compile(
|
||||
|
|
@ -23,9 +24,9 @@ XPG_LOCALE_RE = re.compile(
|
|||
|
||||
def format_list(
|
||||
env: odoo.api.Environment,
|
||||
lst: Sequence[str],
|
||||
lst: Iterable,
|
||||
style: Literal["standard", "standard-short", "or", "or-short", "unit", "unit-short", "unit-narrow"] = "standard",
|
||||
lang_code: Optional[str] = None,
|
||||
lang_code: str | None = None,
|
||||
) -> str:
|
||||
"""
|
||||
Format the items in `lst` as a list in a locale-dependent manner with the chosen style.
|
||||
|
|
@ -56,7 +57,7 @@ def format_list(
|
|||
See https://www.unicode.org/reports/tr35/tr35-49/tr35-general.html#ListPatterns for more details.
|
||||
|
||||
:param env: the current environment.
|
||||
:param lst: the sequence of items to format into a list.
|
||||
:param lst: the iterable of items to format into a list.
|
||||
:param style: the style to format the list with.
|
||||
:param lang_code: the locale (i.e. en_US).
|
||||
:return: the formatted list.
|
||||
|
|
@ -65,7 +66,7 @@ def format_list(
|
|||
# Some styles could be unavailable for the chosen locale
|
||||
if style not in locale.list_patterns:
|
||||
style = "standard"
|
||||
return lists.format_list(lst, style, locale)
|
||||
return lists.format_list([str(el) for el in lst], style, locale)
|
||||
|
||||
|
||||
def py_to_js_locale(locale: str) -> str:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue