From e93cdd9c214daa150282d8b3984b569ab4df2c72 Mon Sep 17 00:00:00 2001 From: Nikita Karamov Date: Sun, 28 Jan 2024 18:34:57 +0100 Subject: [PATCH 1/6] WIP arabic --- src/i18n/translations.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/i18n/translations.ts b/src/i18n/translations.ts index 84db5f8..e8a1033 100644 --- a/src/i18n/translations.ts +++ b/src/i18n/translations.ts @@ -6,6 +6,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +import ar from "./translations/ar.json"; import de from "./translations/de.json"; import en from "./translations/en.json"; import es from "./translations/es.json"; @@ -14,6 +15,7 @@ import nl from "./translations/nl.json"; import ru from "./translations/ru.json"; export const languages = { + ar: { autonym: "العربية", dir: "rtl" }, en: { autonym: "English", dir: "ltr" }, de: { autonym: "Deutsch", dir: "ltr" }, es: { autonym: "Español", dir: "ltr" }, @@ -23,6 +25,7 @@ export const languages = { }; export const strings: Record> = { + ar, en, de, es, From c0ef8cac7326a407cc6e9c911bba3752110ef075 Mon Sep 17 00:00:00 2001 From: Nikita Karamov Date: Mon, 12 Feb 2024 18:46:02 +0100 Subject: [PATCH 2/6] Use `dir="auto"` for big text paragraphs This way, if some of them are untranslated, they will be displayed properly --- src/components/licence.html | 10 ++++++++-- src/components/privacy.html | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/components/licence.html b/src/components/licence.html index 5615424..8d76dbf 100644 --- a/src/components/licence.html +++ b/src/components/licence.html @@ -8,13 +8,19 @@ SPDX-License-Identifier: CC0-1.0
Licence -

+

Share₂Fedi is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License, version 3, as published by the Free Software Foundation.

-

+

Share₂Fedi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License diff --git a/src/components/privacy.html b/src/components/privacy.html index 94de2ab..3dae8ed 100644 --- a/src/components/privacy.html +++ b/src/components/privacy.html @@ -8,7 +8,10 @@ SPDX-License-Identifier: CC0-1.0

Privacy Notice -

+

s2f.kytta.dev is hosted on Vercel. Vercel processes IP addresses, system configuration information, and other information about traffic to and from s2f.kytta.dev. Vercel does not store this information nor does it get shared @@ -20,7 +23,10 @@ SPDX-License-Identifier: CC0-1.0 > for more information.

-

+

When you click the ‘Publish’ button, you’ll get redirected to a Fediverse instance you’ve specified. It may process and/or store your data. Please refer to the privacy policy of the respective instance. From 166d4fcc4461363f673b700779267e466af27fdf Mon Sep 17 00:00:00 2001 From: Nikita Karamov Date: Mon, 12 Feb 2024 19:08:51 +0100 Subject: [PATCH 3/6] Resort languages in the dropdown --- src/i18n/translations.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/i18n/translations.ts b/src/i18n/translations.ts index e8a1033..8d81bf8 100644 --- a/src/i18n/translations.ts +++ b/src/i18n/translations.ts @@ -16,8 +16,8 @@ import ru from "./translations/ru.json"; export const languages = { ar: { autonym: "العربية", dir: "rtl" }, - en: { autonym: "English", dir: "ltr" }, de: { autonym: "Deutsch", dir: "ltr" }, + en: { autonym: "English", dir: "ltr" }, es: { autonym: "Español", dir: "ltr" }, fr: { autonym: "Français", dir: "ltr" }, nl: { autonym: "Nederlands", dir: "ltr" }, @@ -26,8 +26,8 @@ export const languages = { export const strings: Record> = { ar, - en, de, + en, es, fr, nl, From a37470bf9c06c3317e94a19638df10b8cad3e4d2 Mon Sep 17 00:00:00 2001 From: Nikita Karamov Date: Mon, 12 Feb 2024 19:09:33 +0100 Subject: [PATCH 4/6] Format list of supported projects with `Intl` --- src/i18n/engine.ts | 12 ++++++++++++ src/layouts/layout.astro | 12 ++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/i18n/engine.ts b/src/i18n/engine.ts index 3321f28..19ba847 100644 --- a/src/i18n/engine.ts +++ b/src/i18n/engine.ts @@ -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; diff --git a/src/layouts/layout.astro b/src/layouts/layout.astro index 34e64ca..e79f581 100644 --- a/src/layouts/layout.astro +++ b/src/layouts/layout.astro @@ -107,12 +107,16 @@ import package_ from "../../package.json";

Supported projects:

  • - Mastodon (incl. Hometown, Fedibird, - GlitchCafé) + Mastodon (incl. Hometown, Fedibird, GlitchCafé)
  • - Misskey (incl. Firefish/Calckey, - FoundKey, Meisskey) + Misskey (incl. Firefish, Calckey, FoundKey, Meisskey)
  • Friendica
  • Hubzilla
  • From 8d44d9b4d410aa42eb902f46548e480567be7e1a Mon Sep 17 00:00:00 2001 From: Nikita Karamov Date: Mon, 12 Feb 2024 19:24:08 +0100 Subject: [PATCH 5/6] Reduce amount of placeholders --- src/components/instance-select.astro | 16 ++++++---------- src/components/language-select.astro | 2 +- src/i18n/translations/ar.json | 10 +++++----- src/i18n/translations/de.json | 10 +++++----- src/i18n/translations/en.json | 10 +++++----- src/i18n/translations/es.json | 10 +++++----- src/i18n/translations/fr.json | 10 +++++----- src/i18n/translations/nl.json | 10 +++++----- src/i18n/translations/ru.json | 10 +++++----- src/i18n/translations/uk.json | 4 ++-- src/pages/index.astro | 4 ++-- 11 files changed, 46 insertions(+), 50 deletions(-) diff --git a/src/components/instance-select.astro b/src/components/instance-select.astro index 7b8e42c..d0dfe9c 100644 --- a/src/components/instance-select.astro +++ b/src/components/instance-select.astro @@ -10,11 +10,8 @@ const { instance, errors } = Astro.props; --- -