feat(i18n): make admin and catalog components translatable
This commit is contained in:
1 parent
d6111387e4
commit
03774bb411
9 files changed
+142
-87
No files matched your search
@@ -10,6 +10,7 @@ import {
|
||||
Trash2,
|
||||
X,
|
||||
} from "lucide-react";
|
||||
// import { useTranslations } from "next-intl";
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import {
|
||||
|
||||
@@ -147,6 +147,7 @@ export function NitroEditorDialog({
|
||||
onOpenChange,
|
||||
}: NitroEditorDialogProps) {
|
||||
const loadingT = useTranslations("pages.admin.housekeeping");
|
||||
const t = useTranslations("pages.admin.import.furni.nitroEditorDialog");
|
||||
const [metadata, setMetadata] = useState<NitroMetadata | null>(null);
|
||||
const [originalMetadata, setOriginalMetadata] =
|
||||
useState<NitroMetadata | null>(null);
|
||||
@@ -191,7 +192,7 @@ export function NitroEditorDialog({
|
||||
cansiton: result.canSit,
|
||||
canlayon: result.canLay,
|
||||
});
|
||||
toast.success(`Auto-detected: ${result.reason}`);
|
||||
toast.success(t("autoDetected", { reason: result.reason }));
|
||||
};
|
||||
|
||||
const patchMeta = (path: string, value: unknown) => {
|
||||
@@ -217,7 +218,7 @@ export function NitroEditorDialog({
|
||||
const data = await res.json();
|
||||
if (controller.signal.aborted) return;
|
||||
if (!res.ok) {
|
||||
toast.error(data.error || "Failed to load .nitro metadata");
|
||||
toast.error(data.error || t("loadFailed"));
|
||||
closeAfterLoadError();
|
||||
return;
|
||||
}
|
||||
@@ -228,7 +229,7 @@ export function NitroEditorDialog({
|
||||
setOriginalFlags({ ...data.flags });
|
||||
} catch {
|
||||
if (!controller.signal.aborted) {
|
||||
toast.error("Network error loading .nitro metadata");
|
||||
toast.error(t("networkErrorLoad"));
|
||||
closeAfterLoadError();
|
||||
}
|
||||
} finally {
|
||||
@@ -245,7 +246,7 @@ export function NitroEditorDialog({
|
||||
setMetadata(parsed);
|
||||
setJsonError(null);
|
||||
} catch {
|
||||
toast.error("Invalid JSON — fix it before switching tabs");
|
||||
toast.error(t("invalidJsonSwitchTabs"));
|
||||
return;
|
||||
}
|
||||
} else if (activeTab !== "json" && newTab === "json") {
|
||||
@@ -260,7 +261,7 @@ export function NitroEditorDialog({
|
||||
setFlags({ ...originalFlags });
|
||||
setJsonText(JSON.stringify(originalMetadata, null, 2));
|
||||
setJsonError(null);
|
||||
toast.info("Reset to original values");
|
||||
toast.info(t("resetToOriginal"));
|
||||
};
|
||||
|
||||
const handleSave = async () => {
|
||||
@@ -270,7 +271,7 @@ export function NitroEditorDialog({
|
||||
try {
|
||||
metadataToSave = JSON.parse(jsonText);
|
||||
} catch {
|
||||
toast.error("Invalid JSON");
|
||||
toast.error(t("invalidJson"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -289,7 +290,7 @@ export function NitroEditorDialog({
|
||||
|
||||
if (!res.ok) {
|
||||
const err = await res.json().catch(() => ({}));
|
||||
toast.error(err.error || "Save failed");
|
||||
toast.error(err.error || t("saveFailed"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useTranslations } from "next-intl";
|
||||
import { AlertCircle, Check, Loader2, Upload } from "lucide-react";
|
||||
import { useRef, useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
@@ -22,6 +23,9 @@ interface UploadResult {
|
||||
}
|
||||
|
||||
export function UploadFurniClient() {
|
||||
const t = useTranslations(
|
||||
"pages.admin.import.furni.upload.uploadFurniClient",
|
||||
);
|
||||
const nitroRef = useRef<HTMLInputElement>(null);
|
||||
const iconRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
@@ -73,20 +77,19 @@ export function UploadFurniClient() {
|
||||
|
||||
const trimmedClass = classname.trim();
|
||||
if (!CLASSNAME_RE.test(trimmedClass)) {
|
||||
const msg =
|
||||
"Classname must contain only letters, numbers, and underscores";
|
||||
const msg = t("errorClassname");
|
||||
setError(msg);
|
||||
toast.error(msg);
|
||||
return;
|
||||
}
|
||||
if (!nitroFile) {
|
||||
const msg = "Nitro file is required";
|
||||
const msg = t("errorNitroRequired");
|
||||
setError(msg);
|
||||
toast.error(msg);
|
||||
return;
|
||||
}
|
||||
if (nitroFile.size > NITRO_MAX_BYTES) {
|
||||
const msg = "Nitro file must be 50MB or smaller";
|
||||
const msg = t("errorNitroSize");
|
||||
setError(msg);
|
||||
toast.error(msg);
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user