Format list of supported projects with Intl
This commit is contained in:
parent
166d4fcc44
commit
a37470bf9c
2 changed files with 20 additions and 4 deletions
|
@ -72,6 +72,18 @@ export function applyTranslations(language: string) {
|
|||
}
|
||||
}
|
||||
|
||||
if (Intl.ListFormat) {
|
||||
const formatter = new Intl.ListFormat(language, {
|
||||
style: "short",
|
||||
type: "conjunction",
|
||||
});
|
||||
|
||||
for (const node of document.querySelectorAll("[data-enumerate]")) {
|
||||
const dataset = (node as HTMLElement).dataset;
|
||||
node.innerHTML = formatter.format(dataset.enumerate!.split(","));
|
||||
}
|
||||
}
|
||||
|
||||
document.documentElement.lang = language;
|
||||
document.documentElement.dir =
|
||||
languages[language as keyof typeof languages].dir;
|
||||
|
|
|
@ -107,12 +107,16 @@ import package_ from "../../package.json";
|
|||
<p><b data-translate="supportedProjects">Supported projects:</b></p>
|
||||
<ul>
|
||||
<li>
|
||||
Mastodon (<span data-translate="incl">incl.</span> Hometown, Fedibird,
|
||||
GlitchCafé)
|
||||
Mastodon (<span data-translate="incl">incl.</span> <span
|
||||
data-enumerate="Hometown,Fedibird,GlitchCafé"
|
||||
>Hometown, Fedibird, GlitchCafé</span
|
||||
>)
|
||||
</li>
|
||||
<li>
|
||||
Misskey (<span data-translate="incl">incl.</span> Firefish/Calckey,
|
||||
FoundKey, Meisskey)
|
||||
Misskey (<span data-translate="incl">incl.</span> <span
|
||||
data-enumerate="Firefish,Calckey,FoundKey,Meisskey"
|
||||
>Firefish, Calckey, FoundKey, Meisskey</span
|
||||
>)
|
||||
</li>
|
||||
<li>Friendica</li>
|
||||
<li>Hubzilla</li>
|
||||
|
|
Reference in a new issue