Skip to content

Commit

Permalink
fix: localize grouped headers
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiebrynes7 committed Nov 24, 2024
1 parent c75b664 commit 6107a93
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
7 changes: 4 additions & 3 deletions plugin/src/data/transformations/grouping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { Priority } from "@/api/domain/task";
import { DueDate } from "@/data/dueDate";
import { formatAsHeader } from "@/data/dueDateFormatter";
import type { Task } from "@/data/task";
import { t } from "@/i18n";
import { GroupVariant } from "@/query/query";

export type GroupedTasks = {
Expand Down Expand Up @@ -124,14 +125,14 @@ function groupBySection(tasks: Task[]): GroupedTasks[] {
}

function groupByDate(tasks: Task[]): GroupedTasks[] {
// TODO: Localize
const i18n = t().query.groupedHeaders;
const makeHeader = (date: string | undefined): string => {
if (date === undefined) {
return "No due date";
return i18n.noDueDate;
}

if (date === "Overdue") {
return "Overdue";
return i18n.overdue;
}

return formatAsHeader(new DueDate({ recurring: false, date }));
Expand Down
4 changes: 4 additions & 0 deletions plugin/src/i18n/langs/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ export const en: Translations = {
warning: {
header: "Warnings",
},
groupedHeaders: {
noDueDate: "No due date",
overdue: "Overdue",
},
},
commands: {
sync: "Sync with Todoist",
Expand Down
4 changes: 4 additions & 0 deletions plugin/src/i18n/translation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ export type Translations = {
warning: {
header: string;
};
groupedHeaders: {
noDueDate: string;
overdue: string;
};
};
commands: {
sync: string;
Expand Down

0 comments on commit 6107a93

Please sign in to comment.