chore: i18n for rule module

This commit is contained in:
Slinetrac
2025-10-31 18:31:00 +08:00
Unverified
parent 15e73c603b
commit f8cb88c3dd
16 changed files with 433 additions and 26 deletions

View File

@@ -462,10 +462,12 @@ export const RulesEditorViewer = (props: Props) => {
const validateRule = () => {
if ((ruleType.required ?? true) && !ruleContent) {
throw new Error(t("Rule Condition Required"));
throw new Error(
t("components.ruleEditor.form.validation.conditionRequired"),
);
}
if (ruleType.validator && !ruleType.validator(ruleContent)) {
throw new Error(t("Invalid Rule"));
throw new Error(t("components.ruleEditor.form.validation.invalidRule"));
}
const condition = (ruleType.required ?? true) ? ruleContent : "";
@@ -490,7 +492,7 @@ export const RulesEditorViewer = (props: Props) => {
<DialogTitle>
{
<Box display="flex" justifyContent="space-between">
{t("Edit Rules")}
{t("components.ruleEditor.title")}
<Box>
<Button
variant="contained"
@@ -518,7 +520,9 @@ export const RulesEditorViewer = (props: Props) => {
}}
>
<Item>
<ListItemText primary={t("Rule Type")} />
<ListItemText
primary={t("components.ruleEditor.form.labels.type")}
/>
<Autocomplete
size="small"
sx={{ minWidth: "240px" }}
@@ -527,7 +531,12 @@ export const RulesEditorViewer = (props: Props) => {
value={ruleType}
getOptionLabel={(option) => option.name}
renderOption={(props, option) => (
<li {...props} title={t(option.name)}>
<li
{...props}
title={t(
`components.ruleEditor.ruleTypes.${option.name}`,
)}
>
{option.name}
</li>
)}
@@ -537,7 +546,9 @@ export const RulesEditorViewer = (props: Props) => {
<Item
sx={{ display: !(ruleType.required ?? true) ? "none" : "" }}
>
<ListItemText primary={t("Rule Content")} />
<ListItemText
primary={t("components.ruleEditor.form.labels.content")}
/>
{ruleType.name === "RULE-SET" && (
<Autocomplete
@@ -574,7 +585,9 @@ export const RulesEditorViewer = (props: Props) => {
)}
</Item>
<Item>
<ListItemText primary={t("Proxy Policy")} />
<ListItemText
primary={t("components.ruleEditor.form.labels.proxyPolicy")}
/>
<Autocomplete
size="small"
sx={{ minWidth: "240px" }}
@@ -591,7 +604,9 @@ export const RulesEditorViewer = (props: Props) => {
</Item>
{ruleType.noResolve && (
<Item>
<ListItemText primary={t("No Resolve")} />
<ListItemText
primary={t("components.ruleEditor.form.toggles.noResolve")}
/>
<Switch
checked={noResolve}
onChange={() => setNoResolve(!noResolve)}
@@ -613,7 +628,7 @@ export const RulesEditorViewer = (props: Props) => {
}
}}
>
{t("Prepend Rule")}
{t("components.ruleEditor.form.actions.prependRule")}
</Button>
</Item>
<Item>
@@ -631,7 +646,7 @@ export const RulesEditorViewer = (props: Props) => {
}
}}
>
{t("Append Rule")}
{t("components.ruleEditor.form.actions.appendRule")}
</Button>
</Item>
</List>

View File

@@ -141,7 +141,7 @@ export const ProviderButton = () => {
startIcon={<StorageOutlined />}
onClick={() => setOpen(true)}
>
{t("Rule Provider")}
{t("pages.rules.provider.trigger")}
</Button>
<Dialog open={open} onClose={handleClose} maxWidth="sm" fullWidth>
@@ -151,7 +151,9 @@ export const ProviderButton = () => {
justifyContent="space-between"
alignItems="center"
>
<Typography variant="h6">{t("Rule Providers")}</Typography>
<Typography variant="h6">
{t("pages.rules.provider.dialogTitle")}
</Typography>
<Button
variant="contained"
size="small"