diff --git a/public/locales/dk/translations.json b/public/locales/dk/translations.json index a70a249..a462364 100644 --- a/public/locales/dk/translations.json +++ b/public/locales/dk/translations.json @@ -1,4 +1,5 @@ { + "version": 0, "root.description": "Et alternativ til Nix økosystemet", "header.community": "Community", diff --git a/public/locales/en/translations.json b/public/locales/en/translations.json index 5ef1825..de8c8f1 100644 --- a/public/locales/en/translations.json +++ b/public/locales/en/translations.json @@ -1,4 +1,8 @@ { + "version": 0, + "i18n-outdated.title": "Outdated Translation", + "i18n-outdated.description": "This translation has not been updated to the latest version yet.", + "root.description": "An alternative to the Nix ecosystem", "header.community": "Community", diff --git a/src/components/home/Home.astro b/src/components/home/Home.astro index 6d68b0c..5b4e901 100644 --- a/src/components/home/Home.astro +++ b/src/components/home/Home.astro @@ -3,11 +3,25 @@ import Hero from "./Hero.astro"; import Values from "./Values.astro"; import Goals from "./Goals.astro"; import Roadmap from "./Roadmap.astro"; +import I18nOutdated from "../i18n/Outdated.astro"; + +import type { Params } from "../../i18n/utils"; + +const { lang } = Astro.params as Params; +import { isOutdated as i18nIsOutdated } from "../../i18n/utils"; ---
+ { + i18nIsOutdated(lang) && ( +
+ +
+ ) + } +
diff --git a/src/components/i18n/Outdated.astro b/src/components/i18n/Outdated.astro new file mode 100644 index 0000000..61936da --- /dev/null +++ b/src/components/i18n/Outdated.astro @@ -0,0 +1,14 @@ +--- +import { useTranslations } from "../../i18n/utils"; +import type { Params } from "../../i18n/utils"; + +const { lang } = Astro.params as Params; +const translation = useTranslations(lang); +--- + +
+

{translation("i18n-outdated.title")}

+

+ {translation("i18n-outdated.description")} +

+
diff --git a/src/i18n/utils.ts b/src/i18n/utils.ts index d10e23e..1eb25a7 100644 --- a/src/i18n/utils.ts +++ b/src/i18n/utils.ts @@ -11,6 +11,14 @@ export function useTranslations(lang: keyof typeof ui) { }; } +export function isOutdated(lang: keyof typeof ui) { + if ("version" in ui[lang]) { + return ui[lang]["version"] < ui[defaultLang]["version"]; + } else { + return true; + } +} + export const getStaticPaths = (async () => { return Object.keys(languages).map((name) => ({ params: { lang: name as keyof typeof languages },