mirror of
https://framagit.org/framasoft/mobilizon.git
synced 2024-12-26 09:49:12 +00:00
Detect Intl.ListFormat availability and add fallback
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
f9d21c5a38
commit
7f15f2bad1
1 changed files with 8 additions and 2 deletions
|
@ -8,10 +8,16 @@ const shortDisjunctionFormatter = new Intl.ListFormat(undefined, {
|
|||
type: "disjunction",
|
||||
});
|
||||
|
||||
const listFormatAvailable = typeof Intl?.ListFormat === "function";
|
||||
|
||||
export const listShortConjunctionFormatter = (list: Array<string>): string => {
|
||||
return shortConjunctionFormatter.format(list);
|
||||
return listFormatAvailable
|
||||
? shortConjunctionFormatter.format(list)
|
||||
: list.join(",");
|
||||
};
|
||||
|
||||
export const listShortDisjunctionFormatter = (list: Array<string>): string => {
|
||||
return shortDisjunctionFormatter.format(list);
|
||||
return listFormatAvailable
|
||||
? shortDisjunctionFormatter.format(list)
|
||||
: list.join(",");
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue