Skip to content

Commit cdeff25

Browse files
Frontend/i18n: Use namespace constants (#9168)
1 parent 899082f commit cdeff25

5 files changed

Lines changed: 12 additions & 9 deletions

File tree

app/web/components/FlipCard.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Box, Stack, Typography } from "@mui/material";
2+
import { useTranslation } from "i18n";
3+
import { GLOBAL } from "i18n/namespaces";
24
import { ReactNode, useCallback, useState } from "react";
35

4-
import { useTranslation } from "../i18n";
5-
66
export interface FlipCardProps {
77
icon: ReactNode;
88
title: ReactNode;
@@ -20,7 +20,7 @@ export default function FlipCard({
2020
children,
2121
height = { xs: 300, md: 320 },
2222
}: FlipCardProps) {
23-
const { t } = useTranslation(["GLOBAL"]);
23+
const { t } = useTranslation([GLOBAL]);
2424
const [flipped, setFlipped] = useState(false);
2525
const toggle = useCallback(() => setFlipped((f) => !f), []);
2626

app/web/components/Navigation/ReportButton.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
import Button from "components/Button";
1010
import { BugIcon } from "components/Icons";
1111
import { useTranslation } from "i18n";
12+
import { GLOBAL } from "i18n/namespaces";
1213
import { useState } from "react";
1314
import { theme } from "theme";
1415

@@ -40,7 +41,7 @@ export default function ReportButton({
4041
isMenuLink?: boolean;
4142
sx?: SxProps<Theme>;
4243
}) {
43-
const { t } = useTranslation("global");
44+
const { t } = useTranslation(GLOBAL);
4445
const isBelowMd = useMediaQuery(theme.breakpoints.down("md"));
4546
const [isDialogOpen, setIsDialogOpen] = useState(false);
4647

app/web/components/Navigation/ReportDialog.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import StyledLink from "components/StyledLink";
1414
import TextField from "components/TextField";
1515
import { RpcError } from "grpc-web";
1616
import { useTranslation } from "i18n";
17+
import { GLOBAL } from "i18n/namespaces";
1718
import { ReportBugRes } from "proto/bugs_pb";
1819
import { ComponentPropsWithRef, forwardRef, useState } from "react";
1920
import { useForm } from "react-hook-form";
@@ -56,7 +57,7 @@ const StyledReportTypeButton = styled(Button)(() => ({
5657
}));
5758

5859
export default function ReportDialog({ open, onClose }: DialogProps) {
59-
const { t } = useTranslation("global");
60+
const { t } = useTranslation(GLOBAL);
6061

6162
const [type, setType] = useState<"initial" | "bug">("initial");
6263
const {

app/web/components/TOSLink.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { styled } from "@mui/material";
2+
import { GLOBAL } from "i18n/namespaces";
23
import Link from "next/link";
34
import { useTranslation } from "next-i18next";
45
import { tosRoute } from "routes";
@@ -9,7 +10,7 @@ const StyledLink = styled(Link)(({ theme }) => ({
910
}));
1011

1112
export default function TOSLink() {
12-
const { t } = useTranslation("global");
13+
const { t } = useTranslation(GLOBAL);
1314
return (
1415
<StyledLink href={tosRoute} target="_blank">
1516
{t("terms_of_service")}

app/web/features/profile/view/userLabels.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export const ResponseRateLabel = ({ user }: Props) => {
8282
const {
8383
t,
8484
i18n: { language },
85-
} = useTranslation("profile");
85+
} = useTranslation(PROFILE);
8686
// Localize the humanized durations at the call site (no global dayjs locale).
8787
const dayjsLocale = i18nToDayjsLocale(language);
8888

@@ -163,7 +163,7 @@ const AgeAndGenderRenderer = ({ user }: Props) => {
163163
gender,
164164
pronouns,
165165
} = user;
166-
const { t } = useTranslation("profile");
166+
const { t } = useTranslation(PROFILE);
167167

168168
const getBirthdateVerificationIcon = (
169169
status: BirthdateVerificationStatus,
@@ -233,7 +233,7 @@ const AgeAndGenderRenderer = ({ user }: Props) => {
233233
};
234234

235235
export const AgeGenderLanguagesLabels = ({ user }: Props) => {
236-
const { t } = useTranslation("profile");
236+
const { t } = useTranslation(PROFILE);
237237
const { languages } = useLanguages();
238238

239239
return (

0 commit comments

Comments
 (0)