Skip to content

Commit

Permalink
[Feat]: Add Multi-Language Translations For Tasks, Shift Timing, and …
Browse files Browse the repository at this point in the history
…Confirmation Messages (#3377)

* feat: Add multi-language translations for tasks and confirmation messages

* fix:coderabbitai
  • Loading branch information
Innocent-Akim authored Nov 28, 2024
1 parent 936b835 commit 02df050
Show file tree
Hide file tree
Showing 16 changed files with 169 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { clsxm } from '@/app/utils';
import { Modal } from '@/lib/components'
import { CustomSelect, TaskStatus, taskIssues } from '@/lib/features';
import { Item, ManageOrMemberComponent, getNestedValue } from '@/lib/features/manual-time/manage-member-component';
import { useTranslations } from 'next-intl';
import { TranslationHooks, useTranslations } from 'next-intl';
import { ToggleButton } from './EditTaskModal';
import { PlusIcon } from '@radix-ui/react-icons';
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@components/ui/accordion';
Expand Down Expand Up @@ -45,8 +45,8 @@ export function AddTaskModal({ closeModal, isOpen }: IAddTaskModalProps) {

const fields = [
{
label: 'Link to Project',
placeholder: 'Select a project',
label: t('common.LINK_TO_PROJECT'),
placeholder: t('common.SELECT_A_PROJECT'),
isRequired: true,
valueKey: 'id',
displayKey: 'name',
Expand All @@ -65,7 +65,7 @@ export function AddTaskModal({ closeModal, isOpen }: IAddTaskModalProps) {
<div className="flex flex-col w-full gap-4 justify-start overflow-y-auto">
<div className=" w-full mr-[4%]">
<label className="block text-[#282048] dark:text-gray-400 font-medium mb-1">
Task
{t('sidebar.TASKS')}
<span className="text-[#de5505e1] ml-1">*</span>
</label>
<input
Expand All @@ -81,7 +81,7 @@ export function AddTaskModal({ closeModal, isOpen }: IAddTaskModalProps) {
</div>
<div className=" w-full mr-[4%] flex items-center">
<label className="block text-[#282048] dark:text-gray-400 mb-1 px-2">
Types
{t('common.TYPES')}
<span className="text-[#de5505e1] ml-1">*</span>:
</label>
<CustomSelect
Expand All @@ -103,6 +103,7 @@ export function AddTaskModal({ closeModal, isOpen }: IAddTaskModalProps) {
</div>
<div>
<OptimizedAccordion
t={t}
dateRange={dateRange}
timeOptions={timeOptions}
handleFromChange={handleFromChange} />
Expand Down Expand Up @@ -139,7 +140,7 @@ export function AddTaskModal({ closeModal, isOpen }: IAddTaskModalProps) {
</div>

<div className="w-full flex flex-col">
<span className="text-[#282048] dark:text-gray-400 font-medium">Notes</span>
<span className="text-[#282048] dark:text-gray-400 font-medium">{t('common.NOTES')}</span>
<textarea
value={notes}
onChange={(e) => setNotes(e.target.value)}
Expand Down Expand Up @@ -220,12 +221,13 @@ interface Shift {
startTime: string;
endTime: string;
totalHours: string;
dateFrom: Date | string
dateFrom: Date | string,
}
const OptimizedAccordion = ({ dateRange, handleFromChange, timeOptions }: {
const OptimizedAccordion = ({ dateRange, handleFromChange, timeOptions, t }: {
dateRange: { from: Date | null };
handleFromChange: (date: Date | null) => void;
timeOptions: string[];
t: TranslationHooks
}) => {
const [shifts, setShifts] = React.useState<Shift[]>([
{ startTime: '', endTime: '', totalHours: '00:00h', dateFrom: new Date() },
Expand Down Expand Up @@ -294,20 +296,21 @@ const OptimizedAccordion = ({ dateRange, handleFromChange, timeOptions }: {
<AccordionTrigger className="flex flex-row-reverse justify-end h-10 p-1 items-center hover:no-underline">
<div className="flex items-center justify-between w-full">
<label className="block text-[#282048] dark:text-gray-400 mb-1 px-2">
Date and Time
{t('common.DATE_AND_TIME')}
<span className="text-[#de5505e1] ml-1">*</span>:
</label>
<span
onClick={() => handleRemoveShift(index)}
className="hover:underline font-normal text-primary dark:text-primary-light cursor-pointer">
Remove Period
{t('common.REMOVE_PERIOD')}
</span>
</div>
</AccordionTrigger>
<AccordionContent className="p-2">
<div className="flex flex-col gap-2">

<ShiftManagement
t={t}
value={element}
index={index}
onChange={handleShiftChange}
Expand All @@ -323,31 +326,32 @@ const OptimizedAccordion = ({ dateRange, handleFromChange, timeOptions }: {
<div className='bg-[#3826A6] dark:bg-primary-light p-[0.5] rounded text-white'>
<PlusIcon />
</div>
<span className='text-[#3826A6] dark:text-primary-light hover:underline'>Add Another Period</span>
<span className='text-[#3826A6] dark:text-primary-light hover:underline'>{t('common.ADD_ANOTHER_PERIOD')}</span>
</button>
</>

)
};

const ShiftManagement = (
{ onChange, value, index, timeOptions }: {
{ onChange, value, index, timeOptions, t }: {
onChange: (index: number, field: keyof Shift, value: string) => void,
value: Shift, index: number, timeOptions: string[]
value: Shift, index: number, timeOptions: string[],
t: TranslationHooks
}) => {
return (

<>
<div className="w-[212px]">
<span>Date</span>
<span>{t('manualTime.DATE')}</span>
<DatePickerFilter
label={value.dateFrom ? value.dateFrom.toLocaleString() : 'Select Date'}
label={value.dateFrom ? value.dateFrom.toLocaleString() : t('common.SELECT_DATE')}
date={value.dateFrom as Date}
setDate={(value) => onChange(index, 'dateFrom', value as any)}
/>
</div>
<div className="flex flex-col w-full items-start gap-2">
<span className="font-medium">Shift Timing</span>
<span className="font-medium">{t('common.SHIFT_TIMING')}</span>
<div className="flex items-center w-full justify-between gap-4 mb-4">
<ShiftTimingSelect
label="Start"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export function EditTaskModal({ isOpen, closeModal, dataTimesheet }: IEditTaskMo
</div>
<div className="flex items-start flex-col justify-center gap-4">
<div>
<span className="text-[#282048] dark:text-gray-500 ">Task Time</span>
<span className="text-[#282048] dark:text-gray-500 ">{t('dailyPlan.TASK_TIME')}</span>
<div className="flex items-center gap-x-2 ">
<FaRegClock className="text-[#30B366]" />
<span>08:10h</span>
Expand Down Expand Up @@ -172,7 +172,7 @@ export function EditTaskModal({ isOpen, closeModal, dataTimesheet }: IEditTaskMo
</div>
</div>
<div className="w-full flex flex-col">
<span className="text-[#282048] dark:text-gray-400 ">Notes</span>
<span className="text-[#282048] dark:text-gray-400">{t('common.NOTES')}</span>
<textarea
value={notes}
onChange={(e) => setNotes(e.target.value)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ export function DataTableTimeSheet({ data }: { data?: GroupedTimesheet[] }) {
return (
<div className="w-full dark:bg-dark--theme">
<AlertDialogConfirmation
title="Are you sure you want to delete this?"
description={`This action is irreversible. All related data will be lost.`}
title={t('common.DELETE_CONFIRMATION')}
description={t('common.IRREVERSIBLE_ACTION_WARNING')}
confirmText={t('common.DELETE')}
cancelText={t('common.CANCEL')}
isOpen={isDialogOpen}
Expand Down Expand Up @@ -533,7 +533,7 @@ export const StatusTask = ({ timesheet }: { timesheet: TimesheetLog }) => {
<>
<DropdownMenuSub>
<DropdownMenuSubTrigger>
<span>Change status</span>
<span>{t('common.CHANGE_STATUS')}</span>
</DropdownMenuSubTrigger>
<DropdownMenuPortal>
<DropdownMenuSubContent>
Expand Down
11 changes: 11 additions & 0 deletions apps/web/locales/ar.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
{
"TITLE": "إيفر تيمز",
"common": {
"DELETE_CONFIRMATION": "هل أنت متأكد أنك تريد الحذف؟",
"IRREVERSIBLE_ACTION_WARNING": "هذا الإجراء لا رجعة فيه. ستفقد جميع البيانات ذات الصلة.",
"SHIFT_TIMING": "توقيت العمل",
"ADD_ANOTHER_PERIOD": "إضافة فترة أخرى",
"REMOVE_PERIOD": "إزالة الفترة",
"DATE_AND_TIME": "التاريخ والوقت",
"NOTES": "ملاحظات",
"CHANGE_STATUS": "تغيير الحالة",
"TYPES": "أنواع",
"LINK_TO_PROJECT": "رابط إلى المشروع",
"SELECT_A_PROJECT": "اختر مشروعًا",
"ACCEPT": "قبول",
"ACCEPTED": "مقبول",
"REJECT": "رفض",
Expand Down
11 changes: 11 additions & 0 deletions apps/web/locales/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
"PROJECT_BUDGET": "Бюджет на проекта"
},
"common": {
"DELETE_CONFIRMATION": "Сигурни ли сте, че искате да изтриете това?",
"IRREVERSIBLE_ACTION_WARNING": "Това действие е необратимо. Всички свързани данни ще бъдат изгубени.",
"SHIFT_TIMING": "Смяна на времето",
"ADD_ANOTHER_PERIOD": "Добави друг период",
"REMOVE_PERIOD": "Премахване на периода",
"DATE_AND_TIME": "Дата и час",
"NOTES": "Бележки",
"CHANGE_STATUS": "Промяна на състоянието",
"TYPES": "Типове",
"LINK_TO_PROJECT": "Връзка към проект",
"SELECT_A_PROJECT": "Изберете проект",
"ACCEPT": "Приемам",
"ACCEPTED": "Приет",
"REJECT": "Отхвърлям",
Expand Down
11 changes: 11 additions & 0 deletions apps/web/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
"PROJECT_BUDGET": "Projektbudget"
},
"common": {
"DELETE_CONFIRMATION": "Sind Sie sicher, dass Sie dies löschen möchten?",
"IRREVERSIBLE_ACTION_WARNING": "Diese Aktion ist irreversibel. Alle zugehörigen Daten gehen verloren.",
"SHIFT_TIMING": "Schichtzeiten",
"ADD_ANOTHER_PERIOD": "Weitere Periode hinzufügen",
"REMOVE_PERIOD": "Periode entfernen",
"DATE_AND_TIME": "Datum und Uhrzeit",
"NOTES": "Notizen",
"CHANGE_STATUS": "Status ändern",
"TYPES": "Typen",
"LINK_TO_PROJECT": "Projekt verlinken",
"SELECT_A_PROJECT": "Projekt auswählen",
"ACCEPT": "Akzeptieren",
"ACCEPTED": "Akzeptiert",
"REJECT": "Ablehnen",
Expand Down
11 changes: 11 additions & 0 deletions apps/web/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
"PROJECT_BUDGET": "Project Budget"
},
"common": {
"DELETE_CONFIRMATION": "Are you sure you want to delete this?",
"IRREVERSIBLE_ACTION_WARNING": "This action is irreversible. All related data will be lost.",
"SHIFT_TIMING": "Shift Timing",
"ADD_ANOTHER_PERIOD": "Add Another Period",
"REMOVE_PERIOD": "Remove Period",
"DATE_AND_TIME": "Date and Time",
"NOTES": "Notes",
"CHANGE_STATUS": "Change Status",
"TYPES": "Types",
"LINK_TO_PROJECT": "Link to Project",
"SELECT_A_PROJECT": "Select a Project",
"ACCEPT": "Accept",
"ACCEPTED": "Accepted",
"REJECT": "Reject",
Expand Down
11 changes: 11 additions & 0 deletions apps/web/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
"PROJECT_BUDGET": "Presupuesto del Proyecto"
},
"common": {
"DELETE_CONFIRMATION": "¿Estás seguro de que deseas eliminar esto?",
"IRREVERSIBLE_ACTION_WARNING": "Esta acción es irreversible. Todos los datos relacionados se perderán.",
"SHIFT_TIMING": "Horario de turno",
"ADD_ANOTHER_PERIOD": "Agregar otro período",
"REMOVE_PERIOD": "Eliminar período",
"DATE_AND_TIME": "Fecha y hora",
"NOTES": "Notas",
"CHANGE_STATUS": "Cambiar estado",
"TYPES": "Tipos",
"LINK_TO_PROJECT": "Vincular al proyecto",
"SELECT_A_PROJECT": "Seleccionar un proyecto",
"ACCEPT": "Aceptar",
"ACCEPTED": "Aceptado",
"REJECT": "Rechazar",
Expand Down
11 changes: 11 additions & 0 deletions apps/web/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
"PROJECT_BUDGET": "Budget du projet"
},
"common": {
"DELETE_CONFIRMATION": "Êtes-vous sûr de vouloir supprimer cela ?",
"IRREVERSIBLE_ACTION_WARNING": "Cette action est irréversible. Toutes les données associées seront perdues.",
"SHIFT_TIMING": "Temps de poste",
"ADD_ANOTHER_PERIOD": "Ajouter une autre période",
"REMOVE_PERIOD": "Supprimer la période",
"DATE_AND_TIME": "Date et heure",
"NOTES": "Notes",
"CHANGE_STATUS": "Changer le statut",
"TYPES": "Types",
"LINK_TO_PROJECT": "Lien vers le projet",
"SELECT_A_PROJECT": "Sélectionner un projet",
"ACCEPT": "Accepter",
"ACCEPTED": "Accepté",
"REJECT": "Rejeter",
Expand Down
11 changes: 11 additions & 0 deletions apps/web/locales/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
"PROJECT_BUDGET": "תקציב פרויקט"
},
"common": {
"DELETE_CONFIRMATION": "האם אתה בטוח שברצונך למחוק?",
"IRREVERSIBLE_ACTION_WARNING": "פעולה זו בלתי הפיכה. כל הנתונים הקשורים יימחקו.",
"SHIFT_TIMING": "זמן משמרת",
"ADD_ANOTHER_PERIOD": "הוסף תקופה נוספת",
"REMOVE_PERIOD": "הסר תקופה",
"DATE_AND_TIME": "תאריך ושעה",
"NOTES": "הערות",
"CHANGE_STATUS": "שנה מצב",
"TYPES": "סוגים",
"LINK_TO_PROJECT": "קישור לפרויקט",
"SELECT_A_PROJECT": "בחר פרויקט",
"ACCEPT": "קבל",
"ACCEPTED": "התקבל",
"REJECT": "דחה",
Expand Down
11 changes: 11 additions & 0 deletions apps/web/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
"PROJECT_BUDGET": "Budget di progetto"
},
"common": {
"DELETE_CONFIRMATION": "Sei sicuro di voler eliminare questo elemento?",
"IRREVERSIBLE_ACTION_WARNING": "Questa azione è irreversibile. Tutti i dati correlati andranno persi.",
"SHIFT_TIMING": "Orario di turno",
"ADD_ANOTHER_PERIOD": "Aggiungi un altro periodo",
"REMOVE_PERIOD": "Rimuovi periodo",
"DATE_AND_TIME": "Data e ora",
"NOTES": "Note",
"CHANGE_STATUS": "Cambia stato",
"TYPES": "Tipi",
"LINK_TO_PROJECT": "Collega al progetto",
"SELECT_A_PROJECT": "Seleziona un progetto",
"ACCEPT": "Accept",
"ACCEPTED": "Accepted",
"REJECT": "Reject",
Expand Down
11 changes: 11 additions & 0 deletions apps/web/locales/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
"PROJECT_BUDGET": "Projectbudget"
},
"common": {
"DELETE_CONFIRMATION": "Weet u zeker dat u dit wilt verwijderen?",
"IRREVERSIBLE_ACTION_WARNING": "Deze actie is onomkeerbaar. Alle gerelateerde gegevens gaan verloren.",
"SHIFT_TIMING": "Werkrooster",
"ADD_ANOTHER_PERIOD": "Voeg een andere periode toe",
"REMOVE_PERIOD": "Verwijder periode",
"DATE_AND_TIME": "Datum en tijd",
"NOTES": "Notities",
"CHANGE_STATUS": "Wijzig status",
"TYPES": "Typen",
"LINK_TO_PROJECT": "Koppelen aan project",
"SELECT_A_PROJECT": "Selecteer een project",
"ACCEPT": "Accepteren",
"ACCEPTED": "Geaccepteerd",
"REJECT": "Afwijzen",
Expand Down
11 changes: 11 additions & 0 deletions apps/web/locales/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
"PROJECT_BUDGET": "Budżet projektu"
},
"common": {
"DELETE_CONFIRMATION": "Czy na pewno chcesz to usunąć?",
"IRREVERSIBLE_ACTION_WARNING": "Ta akcja jest nieodwracalna. Wszystkie powiązane dane zostaną utracone.",
"SHIFT_TIMING": "Czas zmiany",
"ADD_ANOTHER_PERIOD": "Dodaj kolejny okres",
"REMOVE_PERIOD": "Usuń okres",
"DATE_AND_TIME": "Data i godzina",
"NOTES": "Notatki",
"CHANGE_STATUS": "Zmień status",
"TYPES": "Typy",
"LINK_TO_PROJECT": "Połącz z projektem",
"SELECT_A_PROJECT": "Wybierz projekt",
"ACCEPT": "Akceptuj",
"ACCEPTED": "Zaakceptowane",
"REJECT": "Odrzuć",
Expand Down
12 changes: 12 additions & 0 deletions apps/web/locales/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@
"PROJECT_BUDGET": "Orçamento do Projeto"
},
"common": {
"DELETE_CONFIRMATION": "Tem certeza de que deseja excluir isso?",
"IRREVERSIBLE_ACTION_WARNING": "Esta ação é irreversível. Todos os dados relacionados serão perdidos.",
"SHIFT_TIMING": "Horário de turno",
"ADD_ANOTHER_PERIOD": "Adicionar outro período",
"REMOVE_PERIOD": "Remover período",
"DATE_AND_TIME": "Data e hora",
"NOTES": "Notas",
"CHANGE_STATUS": "Alterar status",
"TYPES": "Tipos",
"LINK_TO_PROJECT": "Vincular ao projeto",
"SELECT_A_PROJECT": "Selecione um projeto",
"TASK_TIME": "Tempo da tarefa",
"ACCEPT": "Aceitar",
"ACCEPTED": "Aceito",
"REJECT": "Rejeitar",
Expand Down
11 changes: 11 additions & 0 deletions apps/web/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
"PROJECT_BUDGET": "Бюджет проекта"
},
"common": {
"DELETE_CONFIRMATION": "Вы уверены, что хотите удалить это?",
"IRREVERSIBLE_ACTION_WARNING": "Это действие необратимо. Все связанные данные будут потеряны.",
"SHIFT_TIMING": "График смен",
"ADD_ANOTHER_PERIOD": "Добавить еще один период",
"REMOVE_PERIOD": "Удалить период",
"DATE_AND_TIME": "Дата и время",
"NOTES": "Заметки",
"CHANGE_STATUS": "Изменить статус",
"TYPES": "Типы",
"LINK_TO_PROJECT": "Ссылка на проект",
"SELECT_A_PROJECT": "Выберите проект",
"ACCEPT": "Принять",
"ACCEPTED": "Принято",
"REJECT": "Отклонить",
Expand Down
Loading

0 comments on commit 02df050

Please sign in to comment.