refactor: consolidate English translations (#6640)
This commit is contained in:
1 parent
81aa704537
commit
9e14a07e64
449 files changed
+3515
-3922
No files matched your search
@@ -7,11 +7,17 @@ describe("createDockerRemovalConfirmation", () => {
|
||||
const remove = vi.fn();
|
||||
const t = vi.fn((key: string, values?: Record<string, string>) => `${key}:${JSON.stringify(values)}`);
|
||||
|
||||
const confirmation = createDockerRemovalConfirmation([{ name: "sonarr" }, { name: "radarr" }], t as never, remove);
|
||||
const confirmation = createDockerRemovalConfirmation(
|
||||
[{ name: "sonarr" }, { name: "radarr" }],
|
||||
t as never,
|
||||
"Remove",
|
||||
remove,
|
||||
);
|
||||
|
||||
expect(remove).not.toHaveBeenCalled();
|
||||
expect(confirmation.title).toContain('"count":"2"');
|
||||
expect(confirmation.children).toContain('"names":"sonarr, radarr"');
|
||||
expect(confirmation.confirmProps.children).toBe("Remove");
|
||||
|
||||
confirmation.onConfirm();
|
||||
expect(remove).toHaveBeenCalledOnce();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { useCallback } from "react";
|
||||
|
||||
import { useConfirmModal } from "@homarr/modals";
|
||||
import { useScopedI18n } from "@homarr/translation/client";
|
||||
import { useI18n } from "@homarr/translation/client";
|
||||
|
||||
interface DockerContainerName {
|
||||
name: string;
|
||||
@@ -11,7 +11,8 @@ interface DockerContainerName {
|
||||
|
||||
export const createDockerRemovalConfirmation = (
|
||||
containers: DockerContainerName[],
|
||||
t: ReturnType<typeof useScopedI18n<"docker.action.remove">>,
|
||||
t: ReturnType<typeof useI18n<"docker.action.remove">>,
|
||||
confirmLabel: string,
|
||||
onConfirm: () => void | Promise<void>,
|
||||
) => ({
|
||||
title: t("confirmation.title", { count: String(containers.length) }),
|
||||
@@ -19,18 +20,19 @@ export const createDockerRemovalConfirmation = (
|
||||
count: String(containers.length),
|
||||
names: containers.map(({ name }) => name).join(", "),
|
||||
}),
|
||||
confirmProps: { children: t("label"), color: "red.9" },
|
||||
confirmProps: { children: confirmLabel, color: "red.9" },
|
||||
onConfirm,
|
||||
});
|
||||
|
||||
export const useDockerContainerRemovalConfirmation = () => {
|
||||
const t = useScopedI18n("docker.action.remove");
|
||||
const t = useI18n("docker.action.remove");
|
||||
const commonT = useI18n("common.action");
|
||||
const { openConfirmModal } = useConfirmModal();
|
||||
|
||||
return useCallback(
|
||||
(containers: DockerContainerName[], onConfirm: () => void | Promise<void>) => {
|
||||
openConfirmModal(createDockerRemovalConfirmation(containers, t, onConfirm));
|
||||
openConfirmModal(createDockerRemovalConfirmation(containers, t, commonT("remove"), onConfirm));
|
||||
},
|
||||
[openConfirmModal, t],
|
||||
[commonT, openConfirmModal, t],
|
||||
);
|
||||
};
|
||||
Reference in new issue
Block a user