mirror of
https://github.com/home-assistant/frontend.git
synced 2026-05-21 23:48:58 +01:00
830d8d2410
* Add type import check to eslint * Add type imports with eslint --fix
27 lines
721 B
TypeScript
27 lines
721 B
TypeScript
import memoizeOne from "memoize-one";
|
|
import type { FrontendLocaleData } from "../../data/translation";
|
|
|
|
export const formatListWithAnds = (
|
|
locale: FrontendLocaleData,
|
|
list: string[]
|
|
) => formatConjunctionList(locale).format(list);
|
|
|
|
export const formatListWithOrs = (locale: FrontendLocaleData, list: string[]) =>
|
|
formatDisjunctionList(locale).format(list);
|
|
|
|
const formatConjunctionList = memoizeOne(
|
|
(locale: FrontendLocaleData) =>
|
|
new Intl.ListFormat(locale.language, {
|
|
style: "long",
|
|
type: "conjunction",
|
|
})
|
|
);
|
|
|
|
const formatDisjunctionList = memoizeOne(
|
|
(locale: FrontendLocaleData) =>
|
|
new Intl.ListFormat(locale.language, {
|
|
style: "long",
|
|
type: "disjunction",
|
|
})
|
|
);
|