From f5a54633dca3599dab82730fd7d550c0289f170f Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 17 Jan 2024 10:22:49 -0300 Subject: add translation completeness from pogen to the UI --- packages/web-util/src/components/Header.tsx | 4 +- packages/web-util/src/components/LangSelector.tsx | 16 +++++--- packages/web-util/src/context/translation.ts | 26 +++++++++++-- packages/web-util/src/hooks/useLang.ts | 36 +++++++++++++++--- packages/web-util/src/index.build.ts | 45 +++++++++++++++++++++++ 5 files changed, 110 insertions(+), 17 deletions(-) (limited to 'packages/web-util/src') diff --git a/packages/web-util/src/components/Header.tsx b/packages/web-util/src/components/Header.tsx index a0587b2ae..e5662fc70 100644 --- a/packages/web-util/src/components/Header.tsx +++ b/packages/web-util/src/components/Header.tsx @@ -3,7 +3,7 @@ import { LangSelector, useTranslationContext } from "../index.browser.js"; import { ComponentChildren, Fragment, VNode, h } from "preact"; import logo from "../assets/logo-2021.svg"; -export function Header({ title, iconLinkURL, sites, supportedLangs, onLogout, children }: +export function Header({ title, iconLinkURL, sites, onLogout, children }: { title: string, iconLinkURL: string, children?: ComponentChildren, onLogout: (() => void) | undefined, sites: Array>, supportedLangs: string[] }): VNode { const { i18n } = useTranslationContext(); const [open, setOpen] = useState(false) @@ -107,7 +107,7 @@ export function Header({ title, iconLinkURL, sites, supportedLangs, onLogout, ch : undefined}
  • - +
  • {/* CHILDREN */} {children} diff --git a/packages/web-util/src/components/LangSelector.tsx b/packages/web-util/src/components/LangSelector.tsx index a8d910129..7deaa0cf4 100644 --- a/packages/web-util/src/components/LangSelector.tsx +++ b/packages/web-util/src/components/LangSelector.tsx @@ -43,9 +43,9 @@ function getLangName(s: keyof LangsNames | string): string { return String(s); } -export function LangSelector({ supportedLangs }: { supportedLangs: string[] }): VNode { +export function LangSelector({ }: {}): VNode { const [updatingLang, setUpdatingLang] = useState(false); - const { lang, changeLanguage } = useTranslationContext(); + const { lang, changeLanguage, completness, supportedLang } = useTranslationContext(); const [hidden, setHidden] = useState(true); useEffect(() => { @@ -66,8 +66,9 @@ export function LangSelector({ supportedLangs }: { supportedLangs: string[] }):