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..cec26f7 100644 --- a/src/components/home/Home.astro +++ b/src/components/home/Home.astro @@ -3,9 +3,17 @@ 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..1a3c48f --- /dev/null +++ b/src/components/i18n/Outdated.astro @@ -0,0 +1,16 @@ +--- +import { useTranslations } from "../../i18n/utils"; +import type { Params } from "../../i18n/utils"; + +const { lang } = Astro.params as Params; +const translation = useTranslations(lang); +--- + + diff --git a/src/i18n/utils.ts b/src/i18n/utils.ts index d10e23e..a2cfbc5 100644 --- a/src/i18n/utils.ts +++ b/src/i18n/utils.ts @@ -11,6 +11,17 @@ export function useTranslations(lang: keyof typeof ui) { }; } +export function isOutdated(lang: keyof typeof ui) { + if ("version" in ui[lang]) { + return ( + (ui[lang] as (typeof ui)[typeof 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 },