mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-16 11:47:54 +01:00
web: localize
This commit is contained in:
committed by
Abdullah Atta
parent
bb1ec22197
commit
e78b245eea
83
apps/desktop/package-lock.json
generated
83
apps/desktop/package-lock.json
generated
@@ -200,25 +200,6 @@
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/@electron/notarize/node_modules/jsonfile": {
|
||||
"version": "6.1.0",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"universalify": "^2.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"graceful-fs": "^4.1.6"
|
||||
}
|
||||
},
|
||||
"node_modules/@electron/notarize/node_modules/universalify": {
|
||||
"version": "2.0.1",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@electron/osx-sign": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/@electron/osx-sign/-/osx-sign-1.3.1.tgz",
|
||||
@@ -315,17 +296,6 @@
|
||||
"node": ">=14.14"
|
||||
}
|
||||
},
|
||||
"node_modules/@electron/universal/node_modules/jsonfile": {
|
||||
"version": "6.1.0",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"universalify": "^2.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"graceful-fs": "^4.1.6"
|
||||
}
|
||||
},
|
||||
"node_modules/@electron/universal/node_modules/minimatch": {
|
||||
"version": "9.0.5",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz",
|
||||
@@ -342,14 +312,6 @@
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/@electron/universal/node_modules/universalify": {
|
||||
"version": "2.0.1",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/aix-ppc64": {
|
||||
"version": "0.24.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.24.0.tgz",
|
||||
@@ -1396,6 +1358,11 @@
|
||||
"file-uri-to-path": "1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/bindings/node_modules/file-uri-to-path": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
|
||||
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw=="
|
||||
},
|
||||
"node_modules/bl": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz",
|
||||
@@ -1475,6 +1442,25 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/buffer/node_modules/ieee754": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
|
||||
"integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/feross"
|
||||
},
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/feross"
|
||||
},
|
||||
{
|
||||
"type": "consulting",
|
||||
"url": "https://feross.org/support"
|
||||
}
|
||||
]
|
||||
},
|
||||
"node_modules/builder-util": {
|
||||
"version": "25.0.3",
|
||||
"resolved": "https://registry.npmjs.org/builder-util/-/builder-util-25.0.3.tgz",
|
||||
@@ -4420,6 +4406,25 @@
|
||||
"url": "https://github.com/sponsors/Borewit"
|
||||
}
|
||||
},
|
||||
"node_modules/token-types/node_modules/ieee754": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
|
||||
"integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/feross"
|
||||
},
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/feross"
|
||||
},
|
||||
{
|
||||
"type": "consulting",
|
||||
"url": "https://feross.org/support"
|
||||
}
|
||||
]
|
||||
},
|
||||
"node_modules/tree-kill": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz",
|
||||
@@ -4541,7 +4546,7 @@
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 4.0.0"
|
||||
"node": ">= 10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/utf8-byte-length": {
|
||||
|
||||
@@ -27,6 +27,7 @@ import { showFilePicker } from "../../utils/file-picker";
|
||||
import { Attachment } from "@notesnook/editor";
|
||||
import { ImagePickerDialog } from "../../dialogs/image-picker-dialog";
|
||||
import { BuyDialog } from "../../dialogs/buy-dialog";
|
||||
import { strings } from "@notesnook/intl";
|
||||
|
||||
const FILE_SIZE_LIMIT = 500 * 1024 * 1024;
|
||||
const IMAGE_SIZE_LIMIT = 50 * 1024 * 1024;
|
||||
@@ -104,8 +105,7 @@ async function pickFile(
|
||||
): Promise<Attachment | undefined> {
|
||||
try {
|
||||
if (file.size > FILE_SIZE_LIMIT)
|
||||
throw new Error("File too big. You cannot add files over 500 MB.");
|
||||
if (!file) return;
|
||||
throw new Error(strings.fileTooLargeDesc(500));
|
||||
|
||||
const hash = await addAttachment(file, options);
|
||||
return {
|
||||
@@ -131,7 +131,7 @@ async function pickImage(
|
||||
): Promise<Attachment | undefined> {
|
||||
try {
|
||||
if (file.size > IMAGE_SIZE_LIMIT)
|
||||
throw new Error("Image too big. You cannot add images over 50 MB.");
|
||||
throw new Error(strings.imageTooLarge(50));
|
||||
if (!file) return;
|
||||
|
||||
const hash = await addAttachment(file, options);
|
||||
|
||||
@@ -374,10 +374,9 @@ const menuItems: (
|
||||
onClick: async () => {
|
||||
const { unlock, lock } = store.get();
|
||||
if (!context?.locked) {
|
||||
if (await lock(note.id))
|
||||
showToast("success", "Note locked successfully!");
|
||||
if (await lock(note.id)) showToast("success", strings.noteLocked());
|
||||
} else if (await unlock(note.id)) {
|
||||
showToast("success", "Note unlocked successfully!");
|
||||
showToast("success", strings.noteUnlocked());
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -827,9 +826,9 @@ async function copyNote(noteId: string, format: "md" | "txt") {
|
||||
if (!result) throw new Error(`Could not convert note to ${format}.`);
|
||||
|
||||
await navigator.clipboard.writeText(result);
|
||||
showToast("success", "Copied!");
|
||||
showToast("success", strings.noteCopied());
|
||||
} catch (e) {
|
||||
if (e instanceof Error)
|
||||
showToast("error", `Failed to copy note: ${e.message}.`);
|
||||
showToast("error", `${strings.failedToCopyNote()}: ${e.message}.`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,12 +203,14 @@ function PublishView(props: PublishViewProps) {
|
||||
password
|
||||
});
|
||||
setPublishId(publishId);
|
||||
showToast("success", strings.notePublished());
|
||||
showToast("success", strings.action("note", 1, "published"));
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
showToast(
|
||||
"error",
|
||||
`${strings.failedToPublish()}: ${(e as Error).message}`
|
||||
`${strings.actionError("note", 1, "published")}: ${
|
||||
(e as Error).message
|
||||
}`
|
||||
);
|
||||
} finally {
|
||||
setIsPublishing(false);
|
||||
@@ -226,12 +228,13 @@ function PublishView(props: PublishViewProps) {
|
||||
await unpublishNote(note.id);
|
||||
setPublishId(undefined);
|
||||
onClose(true);
|
||||
showToast("success", "Note unpublished.");
|
||||
showToast("success", strings.action("note", 1, "unpublished"));
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
showToast(
|
||||
"error",
|
||||
"Note could not be unpublished: " + (e as Error).message
|
||||
`${strings.actionError("note", 1, "unpublished")}: ` +
|
||||
(e as Error).message
|
||||
);
|
||||
} finally {
|
||||
setIsPublishing(false);
|
||||
|
||||
@@ -29,6 +29,7 @@ import { handleDrop } from "../../common/drop-handler";
|
||||
import { EditTagDialog } from "../../dialogs/item-dialog";
|
||||
import { useStore as useSelectionStore } from "../../stores/selection-store";
|
||||
import { Multiselect } from "../../common/multi-select";
|
||||
import { strings } from "@notesnook/intl";
|
||||
|
||||
type TagProps = { item: TagType; totalNotes: number };
|
||||
function Tag(props: TagProps) {
|
||||
@@ -80,7 +81,7 @@ const menuItems: (tag: TagType, ids?: string[]) => MenuItem[] = (
|
||||
{
|
||||
type: "button",
|
||||
key: "edit",
|
||||
title: "Rename tag",
|
||||
title: strings.renameTag(),
|
||||
icon: Edit.path,
|
||||
onClick: () => EditTagDialog.show(tag)
|
||||
},
|
||||
@@ -88,8 +89,8 @@ const menuItems: (tag: TagType, ids?: string[]) => MenuItem[] = (
|
||||
type: "button",
|
||||
key: "shortcut",
|
||||
title: db.shortcuts.exists(tag.id)
|
||||
? "Remove shortcut"
|
||||
: "Create shortcut",
|
||||
? strings.removeShortcut()
|
||||
: strings.addShortcut(),
|
||||
icon: Shortcut.path,
|
||||
onClick: () => appStore.addToShortcuts(tag)
|
||||
},
|
||||
|
||||
@@ -51,7 +51,7 @@ export function UnlockView(props: UnlockViewProps) {
|
||||
) {
|
||||
setIsWrong(true);
|
||||
} else {
|
||||
showToast("error", "Could not unlock: " + e);
|
||||
showToast("error", `${strings.couldNotUnlock()}: ` + e);
|
||||
console.error(e);
|
||||
}
|
||||
} finally {
|
||||
|
||||
@@ -43,7 +43,7 @@ export const AddNotebookDialog = DialogManager.register(
|
||||
|
||||
const onSubmit = useCallback(async () => {
|
||||
if (!title.current.trim())
|
||||
return showToast("error", "Notebook title cannot be empty.");
|
||||
return showToast("error", strings.allFieldsRequired());
|
||||
|
||||
const id = await db.notebooks.add({
|
||||
id: props.notebook?.id,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -18,6 +18,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import { I18n } from "@lingui/core";
|
||||
import { plural, select, t } from "@lingui/macro";
|
||||
type Actions =
|
||||
| "deleted"
|
||||
| "unpinned"
|
||||
| "pinned"
|
||||
| "unpublished"
|
||||
| "published"
|
||||
| "permanentlyDeleted";
|
||||
|
||||
export const strings = {
|
||||
done: () => t`Done`,
|
||||
@@ -254,7 +261,8 @@ export const strings = {
|
||||
tag: () => t`tag`,
|
||||
reminder: () => t`reminder`,
|
||||
color: () => t`color`,
|
||||
attachment: () => t`attachment`
|
||||
attachment: () => t`attachment`,
|
||||
item: () => t`item`
|
||||
},
|
||||
dataTypesCamelCase: {
|
||||
note: () => t`Note`,
|
||||
@@ -262,7 +270,8 @@ export const strings = {
|
||||
tag: () => t`Tag`,
|
||||
reminder: () => t`Reminder`,
|
||||
color: () => t`Color`,
|
||||
attachment: () => t`Attachment`
|
||||
attachment: () => t`Attachment`,
|
||||
item: () => t`Item`
|
||||
},
|
||||
dataTypesPlural: {
|
||||
note: () => t`notes`,
|
||||
@@ -270,7 +279,8 @@ export const strings = {
|
||||
tag: () => t`tags`,
|
||||
reminder: () => t`reminders`,
|
||||
color: () => t`colors`,
|
||||
attachment: () => t`attachments`
|
||||
attachment: () => t`attachments`,
|
||||
item: () => t`items`
|
||||
},
|
||||
dataTypesPluralCamelCase: {
|
||||
note: () => t`Notes`,
|
||||
@@ -280,7 +290,8 @@ export const strings = {
|
||||
color: () => t`Colors`,
|
||||
attachment: () => t`Attachments`,
|
||||
favorite: () => t`Favorites`,
|
||||
monograph: () => t`Monographs`
|
||||
monograph: () => t`Monographs`,
|
||||
item: () => t`Items`
|
||||
},
|
||||
addItem: (referenceType: string) =>
|
||||
t`Add a ${strings.dataTypes[
|
||||
@@ -477,6 +488,7 @@ $headline$: Use starting line of the note as title.`,
|
||||
useAccountPassword: () => t`Use account password`,
|
||||
addColor: () => t`Add color`,
|
||||
unlockNote: () => t`Unlock note`,
|
||||
couldNotUnlock: () => t`Could not unlock`,
|
||||
unlockNoteDesc: () =>
|
||||
t`"Your note will be unencrypted and removed from the vault."`,
|
||||
deleteAllNotes: () => t`Delete all notes`,
|
||||
@@ -840,9 +852,11 @@ $headline$: Use starting line of the note as title.`,
|
||||
encryptingAttachment: () => t`Encrypting attachment`,
|
||||
encryptingAttachmentDesc: (name: string) =>
|
||||
t`Please wait while we encrypt ${name} for upload.`,
|
||||
fileTooLarge: () => t`File too large`,
|
||||
fileTooLarge: () => t`File too big`,
|
||||
fileTooLargeDesc: (sizeInMB: number) =>
|
||||
t`File size should be less than ${sizeInMB}MB`,
|
||||
imageTooLarge: (sizeInMB: number) =>
|
||||
t`Image size should be less than ${sizeInMB}MB`,
|
||||
failToOpen: () => t`Failed to open`,
|
||||
fileMismatch: () => t`File mismatch`,
|
||||
noNoteProperties: () => t`Start writing to create a new note`,
|
||||
@@ -1789,11 +1803,16 @@ All attachments will be downloaded & cached again on access.
|
||||
strings.dataTypesPlural[type as keyof typeof strings.dataTypesPlural]
|
||||
} moved to trash`
|
||||
}),
|
||||
action: (type: string, count: number, action: "deleted" | "unpinned") => {
|
||||
const actions: { [name: string]: any } = {
|
||||
deleted: t`deleted`,
|
||||
unpinned: t`unpinned`
|
||||
};
|
||||
actions: () => ({
|
||||
deleted: t`deleted`,
|
||||
unpinned: t`unpinned`,
|
||||
pinned: t`pinned`,
|
||||
unpublished: t`unpublished`,
|
||||
published: t`published`,
|
||||
permanentlyDeleted: t`permanently deleted`
|
||||
}),
|
||||
action: (type: string, count: number, action: Actions) => {
|
||||
const actions = strings.actions();
|
||||
return plural(count, {
|
||||
one: `${
|
||||
strings.dataTypesCamelCase[type as keyof typeof strings.dataTypes]
|
||||
@@ -1803,6 +1822,17 @@ All attachments will be downloaded & cached again on access.
|
||||
} ${actions[action]}`
|
||||
});
|
||||
},
|
||||
actionError: (type: string, count: number, action: Actions) => {
|
||||
const actions = strings.actions();
|
||||
return plural(count, {
|
||||
one: `${
|
||||
strings.dataTypesCamelCase[type as keyof typeof strings.dataTypes]
|
||||
} could not be ${actions[action]}`,
|
||||
other: `# ${
|
||||
strings.dataTypesPlural[type as keyof typeof strings.dataTypesPlural]
|
||||
} could not be ${actions[action]}`
|
||||
});
|
||||
},
|
||||
deleted: (type: string, count: number) =>
|
||||
plural(count, {
|
||||
one: `${
|
||||
@@ -1842,5 +1872,6 @@ All attachments will be downloaded & cached again on access.
|
||||
backupReadyToDownload: () => t`Your backup is ready to download`,
|
||||
unlockVault: () => t`Unlock vault`,
|
||||
unlockVaultDesc: () => t`Please enter your vault password to continue`,
|
||||
imagePreviewFailed: () => t`This image cannot be previewed`
|
||||
imagePreviewFailed: () => t`This image cannot be previewed`,
|
||||
failedToCopyNote: () => t`Failed to copy note`
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user