Skip to content

Commit ea5db62

Browse files
jschefflsanederchik
authored andcommitted
Translate all components (apache#51243)
* Translate all components * Further component translation * Fix test * Fix re-sorting after rebase * Fix useLogs after review
1 parent af3e3a0 commit ea5db62

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+778
-393
lines changed

airflow-core/src/airflow/ui/src/components/AssetExpression/AndGateNode.tsx

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,41 @@
1818
*/
1919
import { Box, VStack, Badge } from "@chakra-ui/react";
2020
import type { PropsWithChildren } from "react";
21+
import { useTranslation } from "react-i18next";
2122
import { TbLogicAnd } from "react-icons/tb";
2223

23-
export const AndGateNode = ({ children }: PropsWithChildren) => (
24-
<Box
25-
bg="bg.subtle"
26-
border="2px dashed"
27-
borderRadius="lg"
28-
display="inline-block"
29-
minW="fit-content"
30-
p={4}
31-
position="relative"
32-
>
33-
<Badge
34-
alignItems="center"
35-
borderRadius="full"
36-
display="flex"
37-
fontSize="sm"
38-
gap={1}
39-
left="50%"
40-
position="absolute"
41-
px={3}
42-
py={1}
43-
top="-3"
44-
transform="translateX(-50%)"
24+
export const AndGateNode = ({ children }: PropsWithChildren) => {
25+
const { t: translate } = useTranslation("common");
26+
27+
return (
28+
<Box
29+
bg="bg.subtle"
30+
border="2px dashed"
31+
borderRadius="lg"
32+
display="inline-block"
33+
minW="fit-content"
34+
p={4}
35+
position="relative"
4536
>
46-
<TbLogicAnd size={18} />
47-
AND
48-
</Badge>
49-
<VStack align="center" gap={4} mt={3}>
50-
{children}
51-
</VStack>
52-
</Box>
53-
);
37+
<Badge
38+
alignItems="center"
39+
borderRadius="full"
40+
display="flex"
41+
fontSize="sm"
42+
gap={1}
43+
left="50%"
44+
position="absolute"
45+
px={3}
46+
py={1}
47+
top="-3"
48+
transform="translateX(-50%)"
49+
>
50+
<TbLogicAnd size={18} />
51+
{translate("expression.and")}
52+
</Badge>
53+
<VStack align="center" gap={4} mt={3}>
54+
{children}
55+
</VStack>
56+
</Box>
57+
);
58+
};

airflow-core/src/airflow/ui/src/components/AssetExpression/AssetExpression.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
import { Box, Badge } from "@chakra-ui/react";
2020
import { Fragment } from "react";
21+
import { useTranslation } from "react-i18next";
2122
import { TbLogicOr } from "react-icons/tb";
2223

2324
import { AndGateNode } from "./AndGateNode";
@@ -32,6 +33,8 @@ export const AssetExpression = ({
3233
readonly events?: Array<NextRunEvent>;
3334
readonly expression: ExpressionType | null;
3435
}) => {
36+
const { t: translate } = useTranslation("common");
37+
3538
if (expression === null) {
3639
return undefined;
3740
}
@@ -54,7 +57,7 @@ export const AssetExpression = ({
5457
{expression.any && index === expression.any.length - 1 ? undefined : (
5558
<Badge alignItems="center" borderRadius="full" fontSize="sm" px={3} py={1}>
5659
<TbLogicOr size={18} />
57-
OR
60+
{translate("expression.or")}
5861
</Badge>
5962
)}
6063
</Fragment>

airflow-core/src/airflow/ui/src/components/Banner/BackfillBanner.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
import { Box, HStack, Spacer, Text, type ButtonProps } from "@chakra-ui/react";
2020
import { useQueryClient } from "@tanstack/react-query";
21+
import { useTranslation } from "react-i18next";
2122
import { MdPause, MdPlayArrow, MdStop } from "react-icons/md";
2223
import { RiArrowGoBackFill } from "react-icons/ri";
2324

@@ -46,6 +47,7 @@ const buttonProps = {
4647
} satisfies ButtonProps;
4748

4849
const BackfillBanner = ({ dagId }: Props) => {
50+
const { t: translate } = useTranslation("components");
4951
const { data, isLoading } = useBackfillServiceListBackfillsUi({
5052
dagId,
5153
});
@@ -91,7 +93,7 @@ const BackfillBanner = ({ dagId }: Props) => {
9193
<Box bg="blue.solid" borderRadius="full" color="blue.contrast" my="1" px="2" py="1">
9294
<HStack alignItems="center" ml={3}>
9395
<RiArrowGoBackFill />
94-
<Text key="backfill">Backfill in progress:</Text>
96+
<Text key="backfill">{translate("banner.backfillInProgress")}:</Text>
9597
<Text fontSize="sm">
9698
{" "}
9799
<Time datetime={data?.backfills[0]?.from_date} /> - <Time datetime={data?.backfills[0]?.to_date} />
@@ -100,7 +102,7 @@ const BackfillBanner = ({ dagId }: Props) => {
100102
<Spacer flex="max-content" />
101103
<ProgressBar size="xs" visibility="visible" />
102104
<Button
103-
aria-label={backfill.is_paused ? "Unpause backfill" : "Pause backfill"}
105+
aria-label={backfill.is_paused ? translate("banner.unpause") : translate("banner.pause")}
104106
loading={isPausePending || isUnPausePending}
105107
onClick={() => {
106108
togglePause();
@@ -110,7 +112,7 @@ const BackfillBanner = ({ dagId }: Props) => {
110112
{backfill.is_paused ? <MdPlayArrow /> : <MdPause />}
111113
</Button>
112114
<Button
113-
aria-label="Cancel backfill"
115+
aria-label={translate("banner.cancel")}
114116
loading={isStopPending}
115117
onClick={() => {
116118
cancel();

airflow-core/src/airflow/ui/src/components/Clear/columns.tsx

Lines changed: 0 additions & 66 deletions
This file was deleted.

airflow-core/src/airflow/ui/src/components/ConfigForm.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
import { Accordion, Box, Field } from "@chakra-ui/react";
2020
import { type Control, type FieldValues, type Path, Controller } from "react-hook-form";
21+
import { useTranslation } from "react-i18next";
2122

2223
import type { ParamsSpec } from "src/queries/useDagParams";
2324
import { useParamStore } from "src/queries/useParamStore";
@@ -50,6 +51,7 @@ const ConfigForm = <T extends FieldValues = FieldValues>({
5051
setErrors,
5152
setFormError,
5253
}: ConfigFormProps<T>) => {
54+
const { t: translate } = useTranslation("components");
5355
const { conf, setConf } = useParamStore();
5456

5557
const validateAndPrettifyJson = (value: string) => {
@@ -66,11 +68,11 @@ const ConfigForm = <T extends FieldValues = FieldValues>({
6668

6769
return formattedJson;
6870
} catch (error) {
69-
const errorMessage = error instanceof Error ? error.message : "Unknown error occurred.";
71+
const errorMessage = error instanceof Error ? error.message : translate("configForm.unkownError");
7072

7173
setErrors((prev) => ({
7274
...prev,
73-
conf: `Invalid JSON format: ${errorMessage}`,
75+
conf: translate("configForm.invalidJson", { errorMessage }),
7476
}));
7577

7678
return value;
@@ -91,7 +93,9 @@ const ConfigForm = <T extends FieldValues = FieldValues>({
9193
setError={setFormError}
9294
/>
9395
<Accordion.Item key="advancedOptions" value="advancedOptions">
94-
<Accordion.ItemTrigger cursor="button">Advanced Options</Accordion.ItemTrigger>
96+
<Accordion.ItemTrigger cursor="button">
97+
{translate("configForm.advancedOptions")}
98+
</Accordion.ItemTrigger>
9599
<Accordion.ItemContent>
96100
<Box p={4}>
97101
{children}
@@ -100,7 +104,7 @@ const ConfigForm = <T extends FieldValues = FieldValues>({
100104
name={"conf" as Path<T>}
101105
render={({ field }) => (
102106
<Field.Root invalid={Boolean(errors.conf)} mt={6}>
103-
<Field.Label fontSize="md">Configuration JSON</Field.Label>
107+
<Field.Label fontSize="md">{translate("configForm.configJson")}</Field.Label>
104108
<JsonEditor
105109
{...field}
106110
onBlur={() => {

airflow-core/src/airflow/ui/src/components/DagActions/ParseDag.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19+
import { useTranslation } from "react-i18next";
1920
import { AiOutlineFileSync } from "react-icons/ai";
2021

2122
import { Button } from "src/components/ui";
@@ -27,17 +28,18 @@ type Props = {
2728
};
2829

2930
const ParseDag = ({ dagId, fileToken }: Props) => {
31+
const { t: translate } = useTranslation("components");
3032
const { isPending, mutate } = useDagParsing({ dagId });
3133

3234
return (
3335
<Button
34-
aria-label="Reparse Dag"
36+
aria-label={translate("reparseDag")}
3537
loading={isPending}
3638
onClick={() => mutate({ fileToken })}
3739
variant="outline"
3840
>
3941
<AiOutlineFileSync height={5} width={5} />
40-
Reparse Dag
42+
{translate("reparseDag")}
4143
</Button>
4244
);
4345
};

0 commit comments

Comments
 (0)