import React from "react"; import { Link, Routes, Route } from "react-router-dom"; import useSWR from "swr"; import "./index.scss"; import { Loading } from "../ui/atoms/loading"; import { MainContentContainer } from "../ui/atoms/page-content"; import { TranslationDifferences } from "./differences"; import { MissingTranslations } from "./missing"; import { TranslationDashboard } from "./dashboard"; import { useLocale } from "../hooks"; interface Locale { locale: string; language: { English: string; native: string; }; isActive: boolean; count: number; } interface LocalesData { locales: Locale[]; } export default function Translations() { return ( } /> } /> } /> } /> ); } function PickLocale() { const locale = useLocale(); React.useEffect(() => { let title = "All translations"; if (locale.toLowerCase() !== "en-us") { title += ` for ${locale}`; } document.title = title; }, [locale]); const { data: dataLocales, error: errorLocales } = useSWR( locale.toLowerCase() === "en-us" ? "/_translations/" : null, async (url) => { const response = await fetch(url); if (!response.ok) { throw new Error(`${response.status} (${await response.text()})`); } return response.json(); } ); if (locale.toLowerCase() === "en-us") { return ( <> {!dataLocales && !errorLocales && } {errorLocales && (

Server error

{errorLocales.toString()}
)} {dataLocales && } ); } return (
Translation differences {" "} Missing translations {" "} Dashboard
); } function Container({ children }: { children: React.ReactNode }) { return ( {children} ); } function ShowLocales({ locales }: { locales: Locale[] }) { return (

Select locale

{locales.map((locale) => { return ( ); })}
{locale.language.English} ({locale.locale}) {" "} {!locale.isActive && not active} {locale.count.toLocaleString()} documents Translation differences {" "} Missing translations {" "} Dashboard {" "}
); }