Skip to content

Commit

Permalink
fix: translation key
Browse files Browse the repository at this point in the history
  • Loading branch information
gakshita committed Jan 22, 2025
1 parent d641390 commit 68a0955
Show file tree
Hide file tree
Showing 16 changed files with 82 additions and 61 deletions.
73 changes: 44 additions & 29 deletions packages/constants/src/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,53 @@ import {

export const NETWORK_CHOICES: {
key: 0 | 2;
label: string;
i18n_label: string;
description: string;
icon: LucideIcon;
}[] = [
{
key: 0,
label: "workspace_projects.network.private.title",
i18n_label: "workspace_projects.network.private.title",
description: "workspace_projects.network.private.description", //"Accessible only by invite",
icon: Lock,
},
{
key: 2,
label: "workspace_projects.network.public.title",
i18n_label: "workspace_projects.network.public.title",
description: "workspace_projects.network.public.description", //"Anyone in the workspace except Guests can join",
icon: Globe2,
},
];

export const GROUP_CHOICES = {
backlog: "workspace_projects.state.backlog",
unstarted: "workspace_projects.state.unstarted",
started: "workspace_projects.state.started",
completed: "workspace_projects.state.completed",
cancelled: "workspace_projects.state.cancelled",
backlog: {
key: "backlog",
i18n_label: "workspace_projects.state.backlog",
},
unstarted: {
key: "unstarted",
i18n_label: "workspace_projects.state.unstarted",
},
started: {
key: "started",
i18n_label: "workspace_projects.state.started",
},
completed: {
key: "completed",
i18n_label: "workspace_projects.state.completed",
},
cancelled: {
key: "cancelled",
i18n_label: "workspace_projects.state.cancelled",
},
};

export const PROJECT_AUTOMATION_MONTHS = [
{ label: "common.months_count", value: 1 },
{ label: "common.months_count", value: 3 },
{ label: "common.months_count", value: 6 },
{ label: "common.months_count", value: 9 },
{ label: "common.months_count", value: 12 },
{ i18n_label: "common.months_count", value: 1 },
{ i18n_label: "common.months_count", value: 3 },
{ i18n_label: "common.months_count", value: 6 },
{ i18n_label: "common.months_count", value: 9 },
{ i18n_label: "common.months_count", value: 12 },
];

export const PROJECT_UNSPLASH_COVERS = [
Expand All @@ -62,55 +77,55 @@ export const PROJECT_UNSPLASH_COVERS = [

export const PROJECT_ORDER_BY_OPTIONS: {
key: TProjectOrderByOptions;
label: string;
i18n_label: string;
}[] = [
{
key: "sort_order",
label: "workspace_projects.sort.manual",
i18n_label: "workspace_projects.sort.manual",
},
{
key: "name",
label: "workspace_projects.sort.name",
i18n_label: "workspace_projects.sort.name",
},
{
key: "created_at",
label: "workspace_projects.sort.created_at",
i18n_label: "workspace_projects.sort.created_at",
},
{
key: "members_length",
label: "workspace_projects.sort.members_length",
i18n_label: "workspace_projects.sort.members_length",
},
];

export const PROJECT_DISPLAY_FILTER_OPTIONS: {
key: TProjectAppliedDisplayFilterKeys;
label: string;
i18n_label: string;
}[] = [
{
key: "my_projects",
label: "workspace_projects.scope.my_projects",
i18n_label: "workspace_projects.scope.my_projects",
},
{
key: "archived_projects",
label: "workspace_projects.scope.archived_projects",
i18n_label: "workspace_projects.scope.archived_projects",
},
];

export const PROJECT_ERROR_MESSAGES = {
permissionError: {
title: "workspace_projects.error.permission",
message: undefined,
i18n_title: "workspace_projects.error.permission",
i18n_message: undefined,
},
cycleDeleteError: {
title: "error",
message: "workspace_projects.error.cycle_delete",
i18n_title: "error",
i18n_message: "workspace_projects.error.cycle_delete",
},
moduleDeleteError: {
title: "error",
message: "workspace_projects.error.module_delete",
i18n_title: "error",
i18n_message: "workspace_projects.error.module_delete",
},
issueDeleteError: {
title: "error",
message: "workspace_projects.error.issue_delete",
i18n_title: "error",
i18n_message: "workspace_projects.error.issue_delete",
},
};
6 changes: 5 additions & 1 deletion web/app/[workspaceSlug]/(projects)/profile/[userId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ export default function ProfileOverviewPage() {
const group = userProfile?.state_distribution.find((g) => g.state_group === t(key));

if (group) return group;
else return { state_group: t(key) as TStateGroups, state_count: 0 };
else
return {
state_group: t(GROUP_CHOICES[key as keyof typeof GROUP_CHOICES].i18n_label) as TStateGroups,
state_count: 0,
};
});

return (
Expand Down
4 changes: 2 additions & 2 deletions web/ce/components/projects/create/attributes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const ProjectAttributes: FC<Props> = (props) => {
{currentNetwork ? (
<>
<currentNetwork.icon className="h-3 w-3" />
{t(currentNetwork.label)}
{t(currentNetwork.i18n_label)}
</>
) : (
<span className="text-custom-text-400">{t("select_network")}</span>
Expand All @@ -58,7 +58,7 @@ const ProjectAttributes: FC<Props> = (props) => {
<div className="flex items-start gap-2">
<network.icon className="h-3.5 w-3.5" />
<div className="-mt-1">
<p>{t(network.label)}</p>
<p>{t(network.i18n_label)}</p>
<p className="text-xs text-custom-text-400">{t(network.description)}</p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const CustomAnalyticsSidebarHeader = observer(() => {
<div className="mt-4 space-y-4">
<div className="flex items-center gap-2 text-xs">
<h6 className="text-custom-text-200">Network</h6>
<span>{t(NETWORK_CHOICES.find((n) => n.key === projectDetails?.network)?.label ?? "")}</span>
<span>{t(NETWORK_CHOICES.find((n) => n.key === projectDetails?.network)?.i18n_label ?? "")}</span>
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions web/core/components/automation/auto-archive-automation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ export const AutoArchiveAutomation: React.FC<Props> = observer((props) => {
>
<>
{PROJECT_AUTOMATION_MONTHS.map((month) => (
<CustomSelect.Option key={month.label} value={month.value}>
<span className="text-sm">{t(month.label, { month: month.value })}</span>
<CustomSelect.Option key={month.i18n_label} value={month.value}>
<span className="text-sm">{t(month.i18n_label, { month: month.value })}</span>
</CustomSelect.Option>
))}

Expand Down
4 changes: 2 additions & 2 deletions web/core/components/automation/auto-close-automation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ export const AutoCloseAutomation: React.FC<Props> = observer((props) => {
>
<>
{PROJECT_AUTOMATION_MONTHS.map((month) => (
<CustomSelect.Option key={month.label} value={month.value}>
{t(month.label, { month: month.value })}
<CustomSelect.Option key={month.i18n_label} value={month.value}>
{t(month.i18n_label, { month: month.value })}
</CustomSelect.Option>
))}
<button
Expand Down
4 changes: 2 additions & 2 deletions web/core/components/cycles/delete-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ export const CycleDeleteModal: React.FC<ICycleDelete> = observer((props) => {
? PROJECT_ERROR_MESSAGES.permissionError
: PROJECT_ERROR_MESSAGES.cycleDeleteError;
setToast({
title: t(currentError.title),
title: t(currentError.i18n_title),
type: TOAST_TYPE.ERROR,
message: currentError.message && t(currentError.message),
message: currentError.i18n_message && t(currentError.i18n_message),
});
captureCycleEvent({
eventName: CYCLE_DELETED,
Expand Down
4 changes: 2 additions & 2 deletions web/core/components/inbox/modals/delete-issue-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ export const DeleteInboxIssueModal: React.FC<Props> = observer(({ isOpen, onClos
? PROJECT_ERROR_MESSAGES.permissionError
: PROJECT_ERROR_MESSAGES.issueDeleteError;
setToast({
title: t(currentError.title),
title: t(currentError.i18n_title),
type: TOAST_TYPE.ERROR,
message: currentError.message && t(currentError.message),
message: currentError.i18n_message && t(currentError.i18n_message),
});
})
.finally(() => handleClose());
Expand Down
9 changes: 5 additions & 4 deletions web/core/components/issues/delete-issue-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ export const DeleteIssueModal: React.FC<Props> = (props) => {

if (!authorized) {
setToast({
title: t(PROJECT_ERROR_MESSAGES.permissionError.title),
title: t(PROJECT_ERROR_MESSAGES.permissionError.i18n_title),
type: TOAST_TYPE.ERROR,
message: PROJECT_ERROR_MESSAGES.permissionError.message && t(PROJECT_ERROR_MESSAGES.permissionError.message),
message:
PROJECT_ERROR_MESSAGES.permissionError.i18n_message && t(PROJECT_ERROR_MESSAGES.permissionError.i18n_message),
});
onClose();
return;
Expand All @@ -85,9 +86,9 @@ export const DeleteIssueModal: React.FC<Props> = (props) => {
? PROJECT_ERROR_MESSAGES.permissionError
: PROJECT_ERROR_MESSAGES.issueDeleteError;
setToast({
title: t(currentError.title),
title: t(currentError.i18n_title),
type: TOAST_TYPE.ERROR,
message: currentError.message && t(currentError.message),
message: currentError.i18n_message && t(currentError.i18n_message),
});
})
.finally(() => onClose());
Expand Down
9 changes: 5 additions & 4 deletions web/core/components/issues/workspace-draft/delete-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ export const WorkspaceDraftIssueDeleteIssueModal: React.FC<Props> = (props) => {

if (!authorized) {
setToast({
title: t(PROJECT_ERROR_MESSAGES.permissionError.title),
title: t(PROJECT_ERROR_MESSAGES.permissionError.i18n_title),
type: TOAST_TYPE.ERROR,
message: PROJECT_ERROR_MESSAGES.permissionError.message && t(PROJECT_ERROR_MESSAGES.permissionError.message),
message:
PROJECT_ERROR_MESSAGES.permissionError.i18n_message && t(PROJECT_ERROR_MESSAGES.permissionError.i18n_message),
});
onClose();
return;
Expand All @@ -77,9 +78,9 @@ export const WorkspaceDraftIssueDeleteIssueModal: React.FC<Props> = (props) => {
? PROJECT_ERROR_MESSAGES.permissionError
: PROJECT_ERROR_MESSAGES.issueDeleteError;
setToast({
title: t(currentError.title),
title: t(currentError.i18n_title),
type: TOAST_TYPE.ERROR,
message: currentError.message && t(currentError.message),
message: currentError.i18n_message && t(currentError.i18n_message),
});
})
.finally(() => onClose());
Expand Down
4 changes: 2 additions & 2 deletions web/core/components/modules/delete-module-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ export const DeleteModuleModal: React.FC<Props> = observer((props) => {
? PROJECT_ERROR_MESSAGES.permissionError
: PROJECT_ERROR_MESSAGES.moduleDeleteError;
setToast({
title: t(currentError.title),
title: t(currentError.i18n_title),
type: TOAST_TYPE.ERROR,
message: currentError.message && t(currentError.message),
message: currentError.i18n_message && t(currentError.i18n_message),
});
captureModuleEvent({
eventName: MODULE_DELETED,
Expand Down
2 changes: 1 addition & 1 deletion web/core/components/project/applied-filters/access.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const AppliedAccessFilters: React.FC<Props> = observer((props) => {
const accessDetails = NETWORK_CHOICES.find((s) => `${s.key}` === status);
return (
<div key={status} className="flex items-center gap-1 rounded px-1.5 py-1 text-xs bg-custom-background-80">
{accessDetails && t(accessDetails?.label)}
{accessDetails && t(accessDetails?.i18n_label)}
{editable && (
<button
type="button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const AppliedProjectDisplayFilters: React.FC<Props> = observer((props) =>
return (
<>
{values.map((key) => {
const filterLabel = PROJECT_DISPLAY_FILTER_OPTIONS.find((s) => s.key === key)?.label;
const filterLabel = PROJECT_DISPLAY_FILTER_OPTIONS.find((s) => s.key === key)?.i18n_label;
return (
<div key={key} className="flex items-center gap-1 rounded px-1.5 py-1 text-xs bg-custom-background-80">
{filterLabel && t(filterLabel)}
Expand Down
4 changes: 2 additions & 2 deletions web/core/components/project/dropdowns/filters/access.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const FilterAccess: React.FC<Props> = observer((props) => {
const { t } = useTranslation();

const appliedFiltersCount = appliedFilters?.length ?? 0;
const filteredOptions = NETWORK_CHOICES.filter((a) => a.label.includes(searchQuery.toLowerCase()));
const filteredOptions = NETWORK_CHOICES.filter((a) => a.i18n_label.includes(searchQuery.toLowerCase()));

return (
<>
Expand All @@ -37,7 +37,7 @@ export const FilterAccess: React.FC<Props> = observer((props) => {
isChecked={appliedFilters?.includes(`${access.key}`) ? true : false}
onClick={() => handleUpdate(`${access.key}`)}
icon={<access.icon className="h-3 w-3" />}
title={t(access.label)}
title={t(access.i18n_label)}
/>
))
) : (
Expand Down
6 changes: 3 additions & 3 deletions web/core/components/project/dropdowns/order-by.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ export const ProjectOrderByDropdown: React.FC<Props> = (props) => {
{isMobile ? (
<div className="flex text-sm items-center gap-2 neutral-primary text-custom-text-200">
<ArrowDownWideNarrow className="h-3 w-3" />
{orderByDetails && t(orderByDetails?.label)}
{orderByDetails && t(orderByDetails?.i18n_label)}
<ChevronDown className="h-3 w-3" strokeWidth={2} />
</div>
) : (
<div className={cn(getButtonStyling("neutral-primary", "sm"), "px-2 text-custom-text-200")}>
<ArrowDownWideNarrow className="h-3 w-3" />
{orderByDetails && t(orderByDetails?.label)}
{orderByDetails && t(orderByDetails?.i18n_label)}
<ChevronDown className="h-3 w-3" strokeWidth={2} />
</div>
)}
Expand All @@ -61,7 +61,7 @@ export const ProjectOrderByDropdown: React.FC<Props> = (props) => {
else onChange(option.key);
}}
>
{option && t(option?.label)}
{option && t(option?.i18n_label)}
{value?.includes(option.key) && <Check className="h-3 w-3" />}
</CustomMenu.MenuItem>
))}
Expand Down
6 changes: 3 additions & 3 deletions web/core/components/project/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export const ProjectDetailsForm: FC<IProjectDetailsForm> = (props) => {
<span>{watch("identifier")} .</span>
<span className="flex items-center gap-1.5">
{project.network === 0 && <Lock className="h-2.5 w-2.5 text-white " />}
{currentNetwork && t(currentNetwork?.label)}
{currentNetwork && t(currentNetwork?.i18n_label)}
</span>
</span>
</div>
Expand Down Expand Up @@ -347,7 +347,7 @@ export const ProjectDetailsForm: FC<IProjectDetailsForm> = (props) => {
{selectedNetwork ? (
<>
<selectedNetwork.icon className="h-3.5 w-3.5" />
{t(selectedNetwork.label)}
{t(selectedNetwork.i18n_label)}
</>
) : (
<span className="text-custom-text-400">Select network</span>
Expand All @@ -364,7 +364,7 @@ export const ProjectDetailsForm: FC<IProjectDetailsForm> = (props) => {
<div className="flex items-start gap-2">
<network.icon className="h-3.5 w-3.5" />
<div className="-mt-1">
<p>{t(network.label)}</p>
<p>{t(network.i18n_label)}</p>
<p className="text-xs text-custom-text-400">{t(network.description)}</p>
</div>
</div>
Expand Down

0 comments on commit 68a0955

Please sign in to comment.