All files / app/features/translate LanguagePickerSettings.tsx

0% Statements 0/17
0% Branches 0/3
0% Functions 0/3
0% Lines 0/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92                                                                                                                                                                                       
import { Checkbox, FormControlLabel, Link, Typography } from "@mui/material";
import { Trans, useTranslation } from "i18n";
import { LANGUAGE_MAP } from "i18n/constants";
import { GLOBAL } from "i18n/namespaces";
import { useRouter } from "next/router";
import { translateJobURL, translateRoute } from "routes";
 
import Button from "../../components/Button";
import LanguagePickerSelect from "./LanguagePickerSelect";
import { useShowAllLanguages } from "./useShowAllLanguages";
 
interface ChangeLanguageProps {
  className?: string;
}
 
export default function LanguagePickerSettings({
  className,
}: ChangeLanguageProps) {
  const { t } = useTranslation([GLOBAL]);
  const router = useRouter();
  const { locale } = router;
  const languageName = LANGUAGE_MAP[locale || "en"]?.name;
  const { isAvailable, showAllLanguages, setShowAllLanguages } =
    useShowAllLanguages();
 
  return (
    <div className={className}>
      <Typography variant="h2">
        {t("global:language_preference.form_title")}
      </Typography>
      <>
        <Typography variant="body1">
          <Trans
            t={t}
            i18nKey="global:language_preference.current_preferred_language"
            values={{ language: languageName }}
            components={{ lang: <strong /> }}
          />
        </Typography>
        <Typography
          variant="body1"
          sx={{
            marginBottom: "16px",
          }}
        >
          <Link
            href={translateJobURL}
            target="_blank"
            rel="noreferrer noopener"
            underline="hover"
          >
            <strong>{t("global:language_preference.help_translate")}</strong>
          </Link>
        </Typography>
        <LanguagePickerSelect displayMode="rect" />
        <Typography
          sx={{
            mt: 2,
            marginBottom: "16px",
          }}
        >
          <Button onClick={() => router.push(translateRoute)}>
            {t("global:language_preference.translation_progress.view_progress")}
          </Button>
        </Typography>
        {isAvailable && (
          <FormControlLabel
            control={
              <Checkbox
                checked={showAllLanguages}
                onChange={(e) => setShowAllLanguages(e.target.checked)}
              />
            }
            label={
              <div>
                <Typography variant="body1" component="span" fontWeight="bold">
                  {t("global:language_preference.show_all_languages")}
                </Typography>
                <Typography variant="body2" color="text.secondary">
                  {t(
                    "global:language_preference.show_all_languages_description",
                  )}
                </Typography>
              </div>
            }
          />
        )}
      </>
    </div>
  );
}