From 5f70ca4b92b2c1447ad24340587f9a35afe9a720 Mon Sep 17 00:00:00 2001 From: DrMint <29893320+DrMint@users.noreply.github.com> Date: Sun, 30 Jun 2024 20:00:49 +0200 Subject: [PATCH] Updated credit + language switcher on pages --- TODO.md | 3 - src/components/InlineCredits.astro | 9 +- src/components/LanguageOverride.astro | 67 -------- src/components/Maso/MasoActor.astro | 6 +- src/i18n/wordings-keys.ts | 35 ++--- .../api/pages/_components/PageCredits.astro | 147 ++++++++++++++++++ src/pages/[locale]/api/pages/partial.astro | 32 ++-- src/shared/payload/payload-sdk.ts | 8 +- 8 files changed, 185 insertions(+), 122 deletions(-) delete mode 100644 src/components/LanguageOverride.astro create mode 100644 src/pages/[locale]/api/pages/_components/PageCredits.astro diff --git a/TODO.md b/TODO.md index e4fe17a..3555b2e 100644 --- a/TODO.md +++ b/TODO.md @@ -9,15 +9,12 @@ ## Short term -- [Bugs] On android Chrome, the setting button in the header flashes for a few ms when the page is loading - [Bugs] Make sure uploads name are slug-like and with an extension. - [Bugs] Nyupun can't upload subtitles files - [Bugs] https://v3.accords-library.com/en/collectibles/dod-original-soundtrack/scans obi is way too big - [Feat] 404, 500 pages - [Feat] [RichTextContent] Handle relationship - [Feat] [Timeline] Improve layout/spacing on mobile -- [Feat] Display if a content has a source language -- [Feat] [JSLess] Display if a content is available in more than one language - [Bugs] Number of audio players seems limited (on Chrome and Firefox) - [Feat] [RichTextContent] Add autolink block support diff --git a/src/components/InlineCredits.astro b/src/components/InlineCredits.astro index 0b28ce2..7621a25 100644 --- a/src/components/InlineCredits.astro +++ b/src/components/InlineCredits.astro @@ -29,11 +29,8 @@ const { getLocalizedMatch } = await getI18n(Astro.locals.currentLocale); diff --git a/src/components/LanguageOverride.astro b/src/components/LanguageOverride.astro deleted file mode 100644 index 37b4713..0000000 --- a/src/components/LanguageOverride.astro +++ /dev/null @@ -1,67 +0,0 @@ ---- -import MasoActor from "components/Maso/MasoActor.astro"; -import Tooltip from "components/Tooltip.astro"; -import Button from "components/Button.astro"; -import { formatLocale } from "src/utils/format"; -import { getI18n } from "src/i18n/i18n"; - -interface Props { - currentLanguage: string; - currentSourceLanguage: string; - getPartialUrl: (locale: string) => string; - availableLanguages: string[]; -} - -const { currentLanguage, currentSourceLanguage, getPartialUrl, availableLanguages } = Astro.props; -const { t } = await getI18n(Astro.locals.currentLocale); ---- - -{/* ------------------------------------------- HTML ------------------------------------------- */} - -
- {formatLocale(id)} -
-- { - t("global.languageOverride.availableLanguages", { - count: availableLanguages.length, - }) - } -
-{t("pages.credits.currentLocale")}
++ {formatLocale(currentLocale)} + { + sourceLanguage !== currentLocale && ( + + {t("pages.credits.translationLabel", { + locale: formatLocale(sourceLanguage), + })} + + ) + } +
+ +{t("pages.credits.availableLanguages", { count: otherTranslations.length })}
+ + {otherTranslations.map((translation) => ( ++ {formatLocale(translation.language)} + {translation.sourceLanguage !== translation.language && ( + + {t("pages.credits.translationLabel", { + locale: formatLocale(translation.sourceLanguage), + })} + + )} +
+ + {translation.credits.length > 0 &&