refactor(i18n): Improve multilingual support
This commit is contained in:
@@ -3,22 +3,24 @@ import { FormControl, FormField, FormItem, FormLabel, FormMessage } from "@/comp
|
|||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { UseFormReturn } from "react-hook-form";
|
import { UseFormReturn } from "react-hook-form";
|
||||||
import { ServiceFormData } from "./types";
|
import { ServiceFormData } from "./types";
|
||||||
|
import {useLanguage} from "@/contexts/LanguageContext.tsx";
|
||||||
|
|
||||||
interface ServiceBasicFieldsProps {
|
interface ServiceBasicFieldsProps {
|
||||||
form: UseFormReturn<ServiceFormData>;
|
form: UseFormReturn<ServiceFormData>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ServiceBasicFields({ form }: ServiceBasicFieldsProps) {
|
export function ServiceBasicFields({ form }: ServiceBasicFieldsProps) {
|
||||||
|
const { t } = useLanguage();
|
||||||
return (
|
return (
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="name"
|
name="name"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Service Name</FormLabel>
|
<FormLabel>{t('serviceName')}</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input
|
||||||
placeholder="Enter a descriptive name for your service"
|
placeholder={t('serviceNameDesc')}
|
||||||
{...field}
|
{...field}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|||||||
@@ -6,12 +6,14 @@ import { UseFormReturn } from "react-hook-form";
|
|||||||
import { ServiceFormData } from "./types";
|
import { ServiceFormData } from "./types";
|
||||||
import { ServiceUrlField } from "./ServiceUrlField";
|
import { ServiceUrlField } from "./ServiceUrlField";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import {useLanguage} from "@/contexts/LanguageContext.tsx";
|
||||||
|
|
||||||
interface ServiceConfigFieldsProps {
|
interface ServiceConfigFieldsProps {
|
||||||
form: UseFormReturn<ServiceFormData>;
|
form: UseFormReturn<ServiceFormData>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ServiceConfigFields({ form }: ServiceConfigFieldsProps) {
|
export function ServiceConfigFields({ form }: ServiceConfigFieldsProps) {
|
||||||
|
const { t } = useLanguage();
|
||||||
const [isCustomInterval, setIsCustomInterval] = useState(false);
|
const [isCustomInterval, setIsCustomInterval] = useState(false);
|
||||||
const intervalValue = form.watch("interval");
|
const intervalValue = form.watch("interval");
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { Service } from "@/types/service.types";
|
|||||||
import { ServiceRegionalFields } from "./ServiceRegionalFields";
|
import { ServiceRegionalFields } from "./ServiceRegionalFields";
|
||||||
import { getServiceFormDefaults, mapServiceToFormData, mapFormDataToServiceData } from "./serviceFormUtils";
|
import { getServiceFormDefaults, mapServiceToFormData, mapFormDataToServiceData } from "./serviceFormUtils";
|
||||||
import { useQueryClient } from "@tanstack/react-query";
|
import { useQueryClient } from "@tanstack/react-query";
|
||||||
|
import {useLanguage} from "@/contexts/LanguageContext.tsx";
|
||||||
|
|
||||||
interface ServiceFormProps {
|
interface ServiceFormProps {
|
||||||
onSuccess: () => void;
|
onSuccess: () => void;
|
||||||
@@ -30,6 +31,7 @@ export function ServiceForm({
|
|||||||
isEdit = false,
|
isEdit = false,
|
||||||
onSubmitStart
|
onSubmitStart
|
||||||
}: ServiceFormProps) {
|
}: ServiceFormProps) {
|
||||||
|
const { t } = useLanguage();
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
@@ -124,23 +126,23 @@ export function ServiceForm({
|
|||||||
<form onSubmit={form.handleSubmit(handleSubmit)} className="space-y-6 pb-6">
|
<form onSubmit={form.handleSubmit(handleSubmit)} className="space-y-6 pb-6">
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<h3 className="text-sm font-medium text-muted-foreground border-b pb-2">Basic Information</h3>
|
<h3 className="text-sm font-medium text-muted-foreground border-b pb-2">{t('basicInformation')}</h3>
|
||||||
<ServiceBasicFields form={form} />
|
<ServiceBasicFields form={form} />
|
||||||
<ServiceTypeField form={form} />
|
<ServiceTypeField form={form} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<h3 className="text-sm font-medium text-muted-foreground border-b pb-2">Configuration</h3>
|
<h3 className="text-sm font-medium text-muted-foreground border-b pb-2">{t('configuration')}</h3>
|
||||||
<ServiceConfigFields form={form} />
|
<ServiceConfigFields form={form} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<h3 className="text-sm font-medium text-muted-foreground border-b pb-2">Regional Monitoring</h3>
|
<h3 className="text-sm font-medium text-muted-foreground border-b pb-2">{t('regionalMonitoring')}</h3>
|
||||||
<ServiceRegionalFields form={form} />
|
<ServiceRegionalFields form={form} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<h3 className="text-sm font-medium text-muted-foreground border-b pb-2">Notifications</h3>
|
<h3 className="text-sm font-medium text-muted-foreground border-b pb-2">{t('notifications')}</h3>
|
||||||
<ServiceNotificationFields form={form} />
|
<ServiceNotificationFields form={form} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { ServicesTranslations } from '../types/services';
|
|||||||
export const servicesTranslations: ServicesTranslations = {
|
export const servicesTranslations: ServicesTranslations = {
|
||||||
// Dienst-Tabelle
|
// Dienst-Tabelle
|
||||||
serviceName: "Dienstname",
|
serviceName: "Dienstname",
|
||||||
|
serviceNameDesc: "Geben Sie einen aussagekräftigen Namen für Ihren Service ein",
|
||||||
serviceType: "Diensttyp",
|
serviceType: "Diensttyp",
|
||||||
serviceStatus: "Dienststatus",
|
serviceStatus: "Dienststatus",
|
||||||
responseTime: "Antwortzeit",
|
responseTime: "Antwortzeit",
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { ServicesTranslations } from '../types/services';
|
|||||||
|
|
||||||
export const servicesTranslations: ServicesTranslations = {
|
export const servicesTranslations: ServicesTranslations = {
|
||||||
serviceName: "Service Name",
|
serviceName: "Service Name",
|
||||||
|
serviceNameDesc: "Enter a descriptive name for your service",
|
||||||
serviceType: "Service Type",
|
serviceType: "Service Type",
|
||||||
serviceStatus: "Service Status",
|
serviceStatus: "Service Status",
|
||||||
responseTime: "Response Time",
|
responseTime: "Response Time",
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { ServicesTranslations } from '../types/services';
|
|||||||
|
|
||||||
export const servicesTranslations: ServicesTranslations = {
|
export const servicesTranslations: ServicesTranslations = {
|
||||||
serviceName: "サービス名",
|
serviceName: "サービス名",
|
||||||
|
serviceNameDesc: "サービスのわかりやすい名前を入力してください",
|
||||||
serviceType: "サービスタイプ",
|
serviceType: "サービスタイプ",
|
||||||
serviceStatus: "サービスステータス",
|
serviceStatus: "サービスステータス",
|
||||||
responseTime: "応答時間",
|
responseTime: "応答時間",
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { ServicesTranslations } from '../types/services';
|
|||||||
|
|
||||||
export const servicesTranslations: ServicesTranslations = {
|
export const servicesTranslations: ServicesTranslations = {
|
||||||
serviceName: "ឈ្មោះសេវាកម្ម",
|
serviceName: "ឈ្មោះសេវាកម្ម",
|
||||||
|
serviceNameDesc: "បញ្ចូលឈ្មោះពិពណ៌នាសម្រាប់សេវាកម្មរបស់អ្នក",
|
||||||
serviceType: "ប្រភេទសេវាកម្ម",
|
serviceType: "ប្រភេទសេវាកម្ម",
|
||||||
serviceStatus: "ស្ថានភាពសេវាកម្ម",
|
serviceStatus: "ស្ថានភាពសេវាកម្ម",
|
||||||
responseTime: "ពេលវេលាឆ្លើយតប",
|
responseTime: "ពេលវេលាឆ្លើយតប",
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
export interface ServicesTranslations {
|
export interface ServicesTranslations {
|
||||||
serviceName: string;
|
serviceName: string;
|
||||||
|
serviceNameDesc: string;
|
||||||
serviceType: string;
|
serviceType: string;
|
||||||
serviceStatus: string;
|
serviceStatus: string;
|
||||||
responseTime: string;
|
responseTime: string;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { ServicesTranslations } from '../types/services';
|
|||||||
|
|
||||||
export const servicesTranslations: ServicesTranslations = {
|
export const servicesTranslations: ServicesTranslations = {
|
||||||
serviceName: "服务名称",
|
serviceName: "服务名称",
|
||||||
|
serviceNameDesc: "为你的服务输入一个描述性名称",
|
||||||
serviceType: "服务类型",
|
serviceType: "服务类型",
|
||||||
serviceStatus: "服务状态",
|
serviceStatus: "服务状态",
|
||||||
responseTime: "响应时间",
|
responseTime: "响应时间",
|
||||||
|
|||||||
Reference in New Issue
Block a user