Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 50 additions & 2 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
"add": "Add",
"todoDialog.input.placeholder": "Click the help button to learn what to type here",
"todoDialog.footer.update": "Update",
"cancel": "Cancel",
"close": "Close",
"todoDialog.snackbar.emptyInput": "Please enter something into the text field",
"todoDialog.priorityPicker.label": "Priority",
Expand All @@ -97,5 +96,54 @@
"prompt.archive.changeFile.headline": "Choose a File for Archiving",
"prompt.archive.changeFile.text": "To archive completed todos, you need to choose an archive file first",
"prompt.searchFilters.delete.headline": "Delete search filter?",
"prompt.searchFilters.delete.body": "This search filter will be permanently deleted:"
"prompt.searchFilters.delete.body": "This search filter will be permanently deleted:",
"menu.about": "About",
"menu.aboutSleek": "About sleek",
"menu.revealConfigurationFolder": "Reveal configuration folder",
"menu.file": "File",
"menu.view": "View",
"menu.toggleDrawer": "Toggle drawer",
"menu.toggleFileTabs": "Toggle file tabs",
"menu.toggleNavigation": "Toggle navigation",
"menu.toggleTheme": "Toggle theme",
"menu.toggleCompactMode": "Toggle compact mode",
"menu.todos": "Todos",
"menu.addNewTodo": "Add new todo",
"menu.find": "Find",
"menu.toggleCompleted": "Toggle completed",
"menu.closeWindow": "Close window",
"menu.openWindow": "Open window",
"menu.help": "Help",
"menu.changelog": "Changelog",
"menu.reportBugs": "Report bugs",
"menu.discussFeatures": "Discuss new or existing features",
"menu.contributing": "Contributing",
"menu.keyboardShortcuts": "Keyboard shortcuts",
"menu.privacyPolicy": "Privacy policy",
"menu.sponsoring": "Sponsoring",
"menu.developerTools": "Developer tools",
"menu.showSleek": "Show sleek",
"menu.quitSleek": "Quit sleek",
"notification.dueToday": "Due today",
"notification.dueTomorrow": "Due tomorrow",
"notification.dueInDays": "Due in {{count}} days",
"menu.edit": "Edit",
"menu.undo": "Undo",
"menu.redo": "Redo",
"menu.cut": "Cut",
"menu.paste": "Paste",
"menu.selectAll": "Select all",
"menu.hide": "Hide",
"menu.reload": "Reload",
"fileDialog.textFiles": "Text files",
"fileDialog.allFiles": "All files",
"archive.error.todoFileNotDefined": "Todo file is not defined",
"archive.error.archivingFileNotDefined": "Archiving file is not defined",
"archive.error.noCompletedTodosFound": "No completed todos found",
"archive.success": "Successfully archived",
"clipboard.copied": "Copied to clipboard: {{value}}",
"settings.days": " days",
"sorting.ascending": "Ascending order",
"sorting.descending": "Descending order",
"pomodoro.alt": "Pomodoro"
}
142 changes: 95 additions & 47 deletions src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,47 @@
"copy": "复制",
"delete": "删除",
"cancel": "取消",
"openFile": "打开 文件",
"createFile": "创建 文件",
"fileTabs.changeLocation": "更改文件以进行归档",
"openFile": "打开文件",
"createFile": "创建文件",
"fileTabs.changeLocation": "更改归档文件",
"fileTabs.revealTodoFile": "在文件管理器中显示待办文件",
"fileTabs.revealArchivingFile": "在文件管理器中显示归档文件",
"fileTabs.removeFileHeadline": "从 sleek 中删除文件?",
"fileTabs.removeFileText": "它不会从您的硬盘驱动器中删除。",
"fileTabs.removeFileLabel": "删除",
"fileTabs.removeFileHeadline": "从 sleek 中移除文件?",
"fileTabs.removeFileText": "这不会从你的硬盘中删除该文件",
"fileTabs.removeFileLabel": "移除",
"settings": "设置",
"settings.appendCreationDate": "创建任务时附加创建日期",
"settings.appendCreationDate": "创建待办时附加创建日期",
"settings.convertRelativeToAbsoluteDates": "将相对日期转换为绝对日期",
"settings.notificationsAllowed": "发送通知",
"settings.showFileTabs": "显示文件选项卡",
"settings.tray": "最小化到托盘而不是退出应用程序",
"settings.showFileTabs": "显示文件标签页",
"settings.tray": "最小化到托盘,而不是退出应用",
"settings.invertTrayColor": "反转托盘图标颜色",
"settings.startMinimized": "以最小化状态启动应用程序",
"settings.startMinimized": "启动时最小化到托盘",
"settings.colorTheme": "主题",
"settings.system": "跟随系统",
"settings.light": "明亮",
"settings.dark": "暗黑",
"settings.light": "浅色",
"settings.dark": "深色",
"settings.language": "语言",
"settings.notificationThreshold": "通知阈值",
"settings.bulkTodoCreation": "多行文本创建单独的待办事项",
"settings.matomo": "允许Matomo分析",
"settings.notificationThreshold": "通知提前天数",
"settings.bulkTodoCreation": "多行文本分别创建待办",
"settings.matomo": "允许 Matomo 分析",
"settings.zoom": "缩放",
"settings.disableAnimations": "禁用动画",
"settings.useHumanFriendlyDates": "使用人性化日期",
"settings.weekStart": "一周的第一天",
"settings.useHumanFriendlyDates": "使用易读日期",
"settings.weekStart": "每周开始于",
"settings.0": "星期日",
"settings.1": "星期一",
"settings.6": "周六",
"settings.6": "星期六",
"settings.menuBarVisibility": "显示菜单栏",
"settings.compact": "精简视图",
"settings.compact": "紧凑视图",
"attributes": "属性",
"filters": "过滤器",
"filters": "筛选",
"sorting": "排序",
"drawer.filters.showCompleted": "已完成任务",
"drawer.filters.showHidden": "隐藏任务",
"drawer.filters.showCompleted": "已完成的待办",
"drawer.filters.showHidden": "隐藏的待办",
"drawer.filters.thresholdDateInTheFuture": "未来的阈值日期",
"drawer.filters.dueDateInTheFuture": "未来的截止日期",
"drawer.attributes.noAttributesAvailable": "目前无可用属性",
"drawer.attributes.noAttributesAvailable": "暂无可用属性",
"drawer.attributes.today": "今天",
"drawer.attributes.tomorrow": "明天",
"drawer.attributes.nextWeek": "下周",
Expand All @@ -51,33 +51,32 @@
"drawer.attributes.thisWeek": "本周",
"drawer.attributes.thisMonth": "本月",
"drawer.attributes.nextMonth": "下个月",
"drawer.attributes.overdue": "过期",
"drawer.attributes.elapsed": "已过",
"drawer.sorting.fileSorting": "按照它们在文件中出现的顺序排序任务",
"drawer.sorting.sortCompletedLast": "将已完成的任务移动到列表末尾",
"drawer.attributes.overdue": "已逾期",
"drawer.attributes.elapsed": "已开始",
"drawer.sorting.fileSorting": "按文件中的出现顺序排列待办",
"drawer.sorting.sortCompletedLast": "将已完成的待办移到列表末尾",
"shared.attributeMapping.t": "阈值日期",
"shared.attributeMapping.due": "截止日期",
"shared.attributeMapping.projects": "项目",
"shared.attributeMapping.contexts": "上下文",
"shared.attributeMapping.priority": "优先级",
"shared.attributeMapping.rec": "重复",
"shared.attributeMapping.pm": "番茄工作法",
"shared.attributeMapping.pm": "番茄钟",
"shared.attributeMapping.created": "创建日期",
"shared.attributeMapping.completed": "完成日期",
"splashscreen.noFiles.text": "打开一个现有的todo.txt文件或创建一个新的",
"splashscreen.noTodosAvailable.text": "此文件中没有任务",
"splashscreen.noTodosAvailable.create": "创建任务",
"splashscreen.noTodosVisible.text": "没有可见的结果。",
"splashscreen.noTodosVisible.reset": "重置过滤器",
"search.visibleTodos": "显示 {{visible}} 个共 {{total}} 个)待办事项",
"search.addAsTodo": "添加为任务",
"search.filters.create": "创建搜索过滤器",
"splashscreen.noFiles.text": "打开现有 todo.txt 文件,或创建一个新文件",
"splashscreen.noTodosAvailable.text": "这个文件中没有待办",
"splashscreen.noTodosAvailable.create": "创建待办",
"splashscreen.noTodosVisible.text": "没有可见结果",
"splashscreen.noTodosVisible.reset": "重置筛选",
"search.visibleTodos": "显示 {{visible}} 个共 {{total}} 个待办",
"search.addAsTodo": "添加为待办",
"search.filters.create": "创建搜索筛选",
"add": "添加",
"todoDialog.input.placeholder": "点击帮助按钮以了解在此处输入什么",
"todoDialog.input.placeholder": "点击帮助按钮,了解这里可以输入什么",
"todoDialog.footer.update": "更新",
"cancel": "取消",
"close": "关闭",
"todoDialog.snackbar.emptyInput": "请在文本字段中输入内容",
"todoDialog.snackbar.emptyInput": "请在文本框中输入内容",
"todoDialog.priorityPicker.label": "优先级",
"todoDialog.datePicker.t": "阈值",
"todoDialog.datePicker.due": "截止",
Expand All @@ -89,13 +88,62 @@
"todoDialog.recurrencePicker.month": "月",
"todoDialog.recurrencePicker.year": "年",
"todoDialog.recurrencePicker.strict": "严格",
"prompt.delete.headline": "删除任务?",
"prompt.delete.text": "任务将永久从文件中删除",
"prompt.archive.headline": "归档已完成的任务?",
"prompt.archive.text": "这将把所有已完成的待办事项移动到您指定的归档文件中",
"prompt.delete.headline": "删除待办?",
"prompt.delete.text": "该待办将从文件中永久删除",
"prompt.archive.headline": "归档已完成的待办?",
"prompt.archive.text": "这会将所有已完成的待办移动到你指定的归档文件",
"archive": "归档",
"prompt.archive.changeFile.headline": "选择一个文件进行归档",
"prompt.archive.changeFile.text": "要归档已完成的任务,您需要首先选择一个归档文件。",
"prompt.searchFilters.delete.headline": "删除搜索过滤器?",
"prompt.searchFilters.delete.body": "此搜索过滤器将被永久删除:"
"prompt.archive.changeFile.headline": "选择归档文件",
"prompt.archive.changeFile.text": "要归档已完成的待办,需要先选择一个归档文件",
"prompt.searchFilters.delete.headline": "删除搜索筛选?",
"prompt.searchFilters.delete.body": "此搜索筛选将被永久删除:",
"menu.about": "关于",
"menu.aboutSleek": "关于 sleek",
"menu.revealConfigurationFolder": "显示配置文件夹",
"menu.file": "文件",
"menu.view": "视图",
"menu.toggleDrawer": "显示/隐藏抽屉",
"menu.toggleFileTabs": "显示/隐藏文件标签页",
"menu.toggleNavigation": "显示/隐藏导航",
"menu.toggleTheme": "切换主题",
"menu.toggleCompactMode": "切换紧凑模式",
"menu.todos": "待办",
"menu.addNewTodo": "新建待办",
"menu.find": "查找",
"menu.toggleCompleted": "显示/隐藏已完成",
"menu.closeWindow": "关闭窗口",
"menu.openWindow": "打开窗口",
"menu.help": "帮助",
"menu.changelog": "更新日志",
"menu.reportBugs": "报告问题",
"menu.discussFeatures": "讨论新功能或现有功能",
"menu.contributing": "参与贡献",
"menu.keyboardShortcuts": "键盘快捷键",
"menu.privacyPolicy": "隐私政策",
"menu.sponsoring": "赞助",
"menu.developerTools": "开发者工具",
"menu.showSleek": "显示 sleek",
"menu.quitSleek": "退出 sleek",
"notification.dueToday": "今天截止",
"notification.dueTomorrow": "明天截止",
"notification.dueInDays": "{{count}} 天后截止",
"menu.edit": "编辑",
"menu.undo": "撤销",
"menu.redo": "重做",
"menu.cut": "剪切",
"menu.paste": "粘贴",
"menu.selectAll": "全选",
"menu.hide": "隐藏",
"menu.reload": "重新加载",
"fileDialog.textFiles": "文本文件",
"fileDialog.allFiles": "所有文件",
"archive.error.todoFileNotDefined": "未指定待办文件",
"archive.error.archivingFileNotDefined": "未指定归档文件",
"archive.error.noCompletedTodosFound": "没有找到已完成的待办",
"archive.success": "归档成功",
"clipboard.copied": "已复制到剪贴板:{{value}}",
"settings.days": " 天",
"sorting.ascending": "升序",
"sorting.descending": "降序",
"pomodoro.alt": "番茄钟"
}
15 changes: 10 additions & 5 deletions src/main/File/Archive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ import { getActiveFile } from "./Active";
import { readFileContent } from "./File";
import { writeToFile } from "./Write";
import { mainWindow } from "../index";
import { SettingsStore } from "../Stores";
import { TranslateMain } from "../I18n";
import { File } from "@sleek-types";

const COMPLETION_MARKER = "x ";

const t = (key: Parameters<typeof TranslateMain>[0]) =>
TranslateMain(key, SettingsStore.get("language"));

function checkArchiveReadiness(): void {
const activeFile: File | null = getActiveFile();
if (!activeFile) {
throw new Error("Todo file is not defined");
throw new Error(t("archive.error.todoFileNotDefined"));
}
mainWindow!.webContents.send(
"triggerArchiving",
Expand All @@ -31,11 +36,11 @@ function filterByCompletion(content: string, complete: boolean): string {
function archiveTodos(): string {
const activeFile = getActiveFile();
if (!activeFile) {
throw new Error("Todo file is not defined");
throw new Error(t("archive.error.todoFileNotDefined"));
}

if (!activeFile.doneFilePath) {
throw new Error("Archiving file is not defined");
throw new Error(t("archive.error.archivingFileNotDefined"));
}

// Read todo file only once
Expand All @@ -49,7 +54,7 @@ function archiveTodos(): string {
const uncompletedTodos = filterByCompletion(todoContent, false);

if (!completedTodos.trim()) {
throw new Error("No completed todos found");
throw new Error(t("archive.error.noCompletedTodosFound"));
}

const todosFromDoneFile: string = readFileContent(
Expand All @@ -68,7 +73,7 @@ function archiveTodos(): string {
writeToFile(contentForDoneFile, activeFile.doneFilePath);
writeToFile(uncompletedTodos, activeFile.todoFilePath);

return "Successfully archived";
return t("archive.success");
}

export { archiveTodos, checkArchiveReadiness };
29 changes: 17 additions & 12 deletions src/main/File/Dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,27 @@ import {
import path from "path";
import { registerTodoFile, linkDoneFile } from "./File";
import { writeToFile } from "./Write";
import { SettingsStore } from "../Stores";
import { TranslateMain } from "../I18n";

const dialogFilters = [
{
name: "Text files",
extensions: ["txt"],
},
{
name: "All files",
extensions: ["*"],
},
];
const dialogFilters = () => {
const language = SettingsStore.get("language");
return [
{
name: TranslateMain("fileDialog.textFiles", language),
extensions: ["txt"],
},
{
name: TranslateMain("fileDialog.allFiles", language),
extensions: ["*"],
},
];
};

async function openFile(setDoneFile: boolean): Promise<void> {
const result: OpenDialogReturnValue = await dialog.showOpenDialog({
properties: ["openFile"],
filters: dialogFilters,
filters: dialogFilters(),
securityScopedBookmarks: true,
});
if (!result.canceled && result.filePaths.length > 0) {
Expand All @@ -41,7 +46,7 @@ async function createFile(setDoneFile: boolean): Promise<void> {
const defaultFileName = setDoneFile ? "done.txt" : "todo.txt";
const result: SaveDialogReturnValue = await dialog.showSaveDialog({
defaultPath: path.join(app.getPath("documents"), defaultFileName),
filters: dialogFilters,
filters: dialogFilters(),
securityScopedBookmarks: true,
});

Expand Down
41 changes: 41 additions & 0 deletions src/main/I18n.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { app } from "electron";
import en from "../locales/en.json";
import zh from "../locales/zh.json";

type TranslationKey = keyof typeof en;
type Replacements = Record<string, string | number>;

const resources = {
en,
zh,
};

export function GetMainLanguage(
configuredLanguage?: string,
): keyof typeof resources {
const appLocale =
typeof app.getLocale === "function" ? app.getLocale() : "en";
const language = (configuredLanguage || appLocale || "en")
.toLowerCase()
.slice(0, 2);

return language === "zh" ? "zh" : "en";
}

export function TranslateMain(
key: TranslationKey,
configuredLanguage?: string,
replacements: Replacements = {},
): string {
const language = GetMainLanguage(configuredLanguage);
let value = resources[language][key] || resources.en[key] || key;

Object.entries(replacements).forEach(([replacementKey, replacementValue]) => {
value = value.replaceAll(
`{{${replacementKey}}}`,
replacementValue.toString(),
);
});

return value;
}
Loading