Format list of supported projects with `Intl`

This commit is contained in:
Nikita Karamov 2024-02-12 19:09:33 +01:00
parent 166d4fcc44
commit a37470bf9c
No known key found for this signature in database
GPG Key ID: 41D6F71EE78E77CD
2 changed files with 20 additions and 4 deletions

View File

@ -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;

View File

@ -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>&#x0020;<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>&#x0020;<span
data-enumerate="Firefish,Calckey,FoundKey,Meisskey"
>Firefish, Calckey, FoundKey, Meisskey</span
>)
</li>
<li>Friendica</li>
<li>Hubzilla</li>