A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
core: dynamic localized titles and reminder formatting
kashaf-ansari-dev680756a8bd42
diff --git a/apps/mobile/app/components/dialogs/jump-to-section/index.tsx b/apps/mobile/app/components/dialogs/jump-to-section/index.tsxindex 4c020dbf6..4f60fdfc0 100644--- a/apps/mobile/app/components/dialogs/jump-to-section/index.tsx+++ b/apps/mobile/app/components/dialogs/jump-to-section/index.tsx@@ -44,7 +44,6 @@ import BaseDialog from "../../dialog/base-dialog";import { Pressable } from "../../ui/pressable";import Paragraph from "../../ui/typography/paragraph";import { DefaultAppStyles } from "../../../utils/styles";-import { formatGroupTitle } from "@notesnook/common";const JumpToSectionDialog = () => {const scrollRef = useRef<RefObject<FlatList>>(undefined);@@ -208,7 +207,7 @@ const JumpToSectionDialog = () => {textAlign: "center"}}>- {formatGroupTitle(item.group.title)}+ {item.group.title}</Paragraph></Pressable>);diff --git a/apps/mobile/app/components/list-items/headers/section-header.tsx b/apps/mobile/app/components/list-items/headers/section-header.tsxindex 52108e35c..75f47da27 100644--- a/apps/mobile/app/components/list-items/headers/section-header.tsx+++ b/apps/mobile/app/components/list-items/headers/section-header.tsx@@ -39,8 +39,6 @@ import { IconButton } from "../../ui/icon-button";import { Pressable } from "../../ui/pressable";import Heading from "../../ui/typography/heading";-import { formatGroupTitle } from "@notesnook/common";-export { formatGroupTitle };type SectionHeaderProps = {item: GroupHeader;@@ -124,7 +122,7 @@ export const SectionHeader = React.memo<? screen === "Search"? strings.results(itemCount || 0): strings.pinned().toUpperCase()- : formatGroupTitle(item.title).toUpperCase()}+ : item.title.toUpperCase()}</Heading></Pressable>diff --git a/apps/mobile/app/components/paywall/index.tsx b/apps/mobile/app/components/paywall/index.tsxindex 69525943f..35194aece 100644--- a/apps/mobile/app/components/paywall/index.tsx+++ b/apps/mobile/app/components/paywall/index.tsx@@ -738,24 +738,28 @@ const ComparePlans = React.memo(gap: 10}}>- {["Features", "Free", "Essential", "Pro", "Believer"].map(- (plan, index) => (- <View- key={plan}- style={{- width: index === 0 ? 150 : 120,- paddingHorizontal: 16,- paddingVertical: 12,- backgroundColor:- index === 0 ? colors.secondary.background : undefined,- borderBottomWidth: index === 0 ? 1 : undefined,- borderBottomColor: colors.primary.border- }}- >- <Heading size={AppFontSize.sm}>{plan}</Heading>- </View>- )- )}+ {[+ { id: "features", title: strings.features() },+ { id: "free", title: strings.planMetadataFree() },+ { id: "essential", title: strings.planMetadataEssential() },+ { id: "pro", title: strings.planMetadataPro() },+ { id: "believer", title: strings.planMetadataBeliever() }+ ].map((column, index) => (+ <View+ key={column.id}+ style={{+ width: index === 0 ? 150 : 120,+ paddingHorizontal: 16,+ paddingVertical: 12,+ backgroundColor:+ index === 0 ? colors.secondary.background : undefined,+ borderBottomWidth: index === 0 ? 1 : undefined,+ borderBottomColor: colors.primary.border+ }}+ >+ <Heading size={AppFontSize.sm}>{column.title}</Heading>+ </View>+ ))}</View>{getFeaturesTable().map((item, keyIndex) => {@@ -855,8 +859,7 @@ const ComparePlans = React.memo(</View></ScrollView>);- },- () => true+ });ComparePlans.displayName = "ComparePlans";diff --git a/apps/mobile/app/components/ui/reminder-time/index.tsx b/apps/mobile/app/components/ui/reminder-time/index.tsxindex 7978f4eb9..2c1e8de19 100644--- a/apps/mobile/app/components/ui/reminder-time/index.tsx+++ b/apps/mobile/app/components/ui/reminder-time/index.tsx@@ -28,24 +28,6 @@ import { strings } from "@notesnook/intl";import { Reminder } from "@notesnook/core";import { DefaultAppStyles } from "../../../utils/styles";-function localizeReminderTime(time?: string): string | undefined {- if (!time) return undefined;- if (time === "Ongoing") return strings.ongoing();- if (time.startsWith("Snoozed until ")) {- return strings.snoozedUntil(time.replace("Snoozed until ", ""));- }- let result = time;- if (result.startsWith("Upcoming: ")) {- result = `${strings.upcoming()}: ${result.slice(10)}`;- } else if (result.startsWith("Last: ")) {- result = `${strings.last()}: ${result.slice(6)}`;- }- return result- .replace("Today", strings.today())- .replace("Tomorrow", strings.tomorrow())- .replace("Yesterday", strings.yesterday());-}-export const ReminderTime = ({checkIsActive = true,style,@@ -60,13 +42,13 @@ export const ReminderTime = ({} & ButtonProps) => {const { colors } = useThemeColors();const reminder = props.reminder;- const rawTime = !reminder+ const time = !reminder? undefined: getFormattedReminderTime(reminder, props.short || false);- const time = localizeReminderTime(rawTime);const isTodayOrTomorrow =- (rawTime?.includes("Today") || rawTime?.includes("Tomorrow")) &&- !rawTime?.includes("Last");+ time &&+ (time.includes(strings.today()) || time.includes(strings.tomorrow())) &&+ !time.includes(strings.last());const isActive =checkIsActive && reminder ? isReminderActive(reminder) : true;diff --git a/apps/mobile/metro.config.js b/apps/mobile/metro.config.jsindex eacf4df4d..75fb949b4 100644--- a/apps/mobile/metro.config.js+++ b/apps/mobile/metro.config.js@@ -65,6 +65,11 @@ mergedConfig.resolver = {return context.resolveRequest(context, result, platform);}+ if (moduleName === "@notesnook/intl") {+ const result = require.resolve(moduleName); // gets CommonJS version+ return context.resolveRequest(context, result, platform);+ }+if (moduleName.includes("zustand")) {const result = require.resolve(moduleName); // gets CommonJS versionreturn context.resolveRequest(context, result, platform);diff --git a/apps/web/src/components/group-header/index.tsx b/apps/web/src/components/group-header/index.tsxindex 1dcb12893..4e4dfd488 100644--- a/apps/web/src/components/group-header/index.tsx+++ b/apps/web/src/components/group-header/index.tsx@@ -44,17 +44,28 @@ import {GroupingKey} from "@notesnook/core";import { strings } from "@notesnook/intl";-import { formatGroupTitle } from "@notesnook/common";import { useStore as useSearchStore } from "../../stores/search-store";import type { Context } from "../list-container/types";const groupByToTitleMap = {- none: "None",- default: "Default",- abc: "A - Z",- year: "Year",- week: "Week",- month: "Month"+ get none() {+ return strings.groupByStrings.none();+ },+ get default() {+ return strings.groupByStrings.default();+ },+ get abc() {+ return strings.groupByStrings.abc();+ },+ get year() {+ return strings.groupByStrings.year();+ },+ get week() {+ return strings.groupByStrings.week();+ },+ get month() {+ return strings.groupByStrings.month();+ }};type GroupingMenuOptions = {@@ -72,21 +83,21 @@ const groupByMenu: (options: GroupingMenuOptions) => MenuItem | null = (options.groupingKey === "reminders" || options.isSearching? null: {- type: "button",- key: "groupBy",- title: strings.groupBy(),- icon: GroupBy.path,- menu: {- items: map(options, [- { key: "none", title: strings.groupByStrings.none() },- { key: "default", title: strings.groupByStrings.default() },- { key: "year", title: strings.groupByStrings.year() },- { key: "month", title: strings.groupByStrings.month() },- { key: "week", title: strings.groupByStrings.week() },- { key: "abc", title: strings.groupByStrings.abc() }- ])- }- };+ type: "button",+ key: "groupBy",+ title: strings.groupBy(),+ icon: GroupBy.path,+ menu: {+ items: map(options, [+ { key: "none", title: strings.groupByStrings.none() },+ { key: "default", title: strings.groupByStrings.default() },+ { key: "year", title: strings.groupByStrings.year() },+ { key: "month", title: strings.groupByStrings.month() },+ { key: "week", title: strings.groupByStrings.week() },+ { key: "abc", title: strings.groupByStrings.abc() }+ ])+ }+ };const orderByMenu: (options: GroupingMenuOptions) => MenuItem = (options) => ({type: "button",@@ -98,8 +109,8 @@ const orderByMenu: (options: GroupingMenuOptions) => MenuItem = (options) => ({? OrderAtoZ.path: OrderOldestNewest.path: options.groupOptions.sortBy === "title"- ? OrderZtoA.path- : OrderNewestOldest.path,+ ? OrderZtoA.path+ : OrderNewestOldest.path,menu: {items: map(options, [{@@ -108,10 +119,10 @@ const orderByMenu: (options: GroupingMenuOptions) => MenuItem = (options) => ({options.groupOptions.sortBy === "title"? strings.aToZ(): options.groupOptions.sortBy === "dueDate"- ? strings.earliestFirst()- : options.groupOptions.sortBy === "relevance"- ? strings.leastRelevantFirst()- : strings.oldestToNewest()+ ? strings.earliestFirst()+ : options.groupOptions.sortBy === "relevance"+ ? strings.leastRelevantFirst()+ : strings.oldestToNewest()},{key: "desc",@@ -119,10 +130,10 @@ const orderByMenu: (options: GroupingMenuOptions) => MenuItem = (options) => ({options.groupOptions.sortBy === "title"? strings.zToA(): options.groupOptions.sortBy === "dueDate"- ? strings.latestFirst()- : options.groupOptions.sortBy === "relevance"- ? strings.mostRelevantFirst()- : strings.newestToOldest()+ ? strings.latestFirst()+ : options.groupOptions.sortBy === "relevance"+ ? strings.mostRelevantFirst()+ : strings.newestToOldest()}])}@@ -205,8 +216,8 @@ function getGroupOptions(: context?.type === "notebook" ||context?.type === "tag" ||context?.type === "color"- ? db.settings.getGroupOptionsById(context.id, context.type)- : db.settings.getGroupOptions(groupingKey);+ ? db.settings.getGroupOptionsById(context.id, context.type)+ : db.settings.getGroupOptions(groupingKey);}async function setGroupOptions(@@ -334,7 +345,7 @@ function GroupHeader(props: GroupHeaderProps) {const groupItems = await groups();const items: MenuItem[] = groupItems.map(({ group, index }) => {- const groupTitle = formatGroupTitle(group.title.toString());+ const groupTitle = group.title.toString();return {type: "button",key: groupTitle,@@ -384,10 +395,13 @@ function GroupHeader(props: GroupHeaderProps) {sx={{fontSize: "subBody",fontWeight: "medium",- color: title === "Conflicted" ? "error" : "accent"+ color:+ title === strings.conflicted() || title === "Conflicted"+ ? "error"+ : "accent"}}>- {formatGroupTitle(title).toUpperCase()}+ {title.toUpperCase()}</Text>{index === 0 && (@@ -396,9 +410,8 @@ function GroupHeader(props: GroupHeaderProps) {<IconButtontestId={`${groupingKey}-sort-button`}icon={groupOptions.sortDirection === "asc" ? SortAsc : SortDesc}- title={`Grouped by ${- groupByToTitleMap[groupOptions.groupBy || "default"]- }`}+ title={`Grouped by ${groupByToTitleMap[groupOptions.groupBy || "default"]+ }`}onClick={() => {const groupOptions = getGroupOptions(context,diff --git a/apps/web/src/components/reminder/index.tsx b/apps/web/src/components/reminder/index.tsxindex 42ce209b0..f5a60c701 100644--- a/apps/web/src/components/reminder/index.tsx+++ b/apps/web/src/components/reminder/index.tsx@@ -45,13 +45,6 @@ import { EditReminderDialog } from "../../dialogs/add-reminder-dialog";import { useStore as useSelectionStore } from "../../stores/selection-store";import { strings } from "@notesnook/intl";-const RECURRING_MODE_MAP = {- week: "Weekly",- day: "Daily",- month: "Monthly",- year: "Yearly"-} as const;-const PRIORITY_ICON_MAP = {silent: Silent,vibrate: Vibrate,@@ -101,7 +94,11 @@ function Reminder(props: ReminderProps) {>{reminder.disabled ? null : <PriorityIcon size={14} />}{reminder.disabled ? (- <IconTag icon={ReminderOff} text={"Disabled"} testId={"disabled"} />+ <IconTag+ icon={ReminderOff}+ text={strings.disabled()}+ testId={"disabled"}+ />) : (<IconTagicon={Clock}@@ -116,7 +113,7 @@ function Reminder(props: ReminderProps) {{reminder.mode === "repeat" && reminder.recurringMode && (<IconTagicon={Refresh}- text={RECURRING_MODE_MAP[reminder.recurringMode]}+ text={strings.recurringModes(reminder.recurringMode)}testId={`recurring-mode`}/>)}diff --git a/apps/web/src/dialogs/reminder-preview-dialog.tsx b/apps/web/src/dialogs/reminder-preview-dialog.tsxindex 42409e72e..7b2b6da39 100644--- a/apps/web/src/dialogs/reminder-preview-dialog.tsx+++ b/apps/web/src/dialogs/reminder-preview-dialog.tsx@@ -32,13 +32,6 @@ export type ReminderPreviewDialogProps = BaseDialogProps<false> & {reminder: Reminder;};-const RECURRING_MODE_MAP = {- week: "Weekly",- day: "Daily",- month: "Monthly",- year: "Yearly"-} as const;-const SNOOZE_TIMES = [{id: "5-min",@@ -85,7 +78,7 @@ export const ReminderPreviewDialog = DialogManager.register({reminder.mode === "repeat" && reminder.recurringMode && (<IconTagicon={Refresh}- text={RECURRING_MODE_MAP[reminder.recurringMode]}+ text={strings.recurringModes(reminder.recurringMode)}/>)}<IconTag icon={Clock} text={getFormattedReminderTime(reminder)} />diff --git a/packages/common/src/utils/format-group-title.ts b/packages/common/src/utils/format-group-title.tsdeleted file mode 100644index 064cdcb1b..000000000--- a/packages/common/src/utils/format-group-title.ts+++ /dev/null@@ -1,37 +0,0 @@-/*-This file is part of the Notesnook project (https://notesnook.com/)--Copyright (C) 2023 Streetwriters (Private) Limited--This program is free software: you can redistribute it and/or modify-it under the terms of the GNU General Public License as published by-the Free Software Foundation, either version 3 of the License, or-(at your option) any later version.--This program is distributed in the hope that it will be useful,-but WITHOUT ANY WARRANTY; without even the implied warranty of-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-GNU General Public License for more details.--You should have received a copy of the GNU General Public License-along with this program. If not, see <http://www.gnu.org/licenses/>.-*/--import { strings } from "@notesnook/intl";--const GROUP_TITLES: Record<string, () => string> = {- pinned: strings.pinned,- recent: strings.recent,- "last week": strings.lastWeek,- older: strings.older,- conflicted: strings.conflicted,- all: strings.all,- active: strings.active,- inactive: strings.inactive-};--export function formatGroupTitle(title?: string): string {- if (!title) return "";- const resolve = GROUP_TITLES[title.toLowerCase()];- return resolve ? resolve() : title;-}diff --git a/packages/common/src/utils/index.ts b/packages/common/src/utils/index.tsindex 38718c610..4bee44237 100644--- a/packages/common/src/utils/index.ts+++ b/packages/common/src/utils/index.ts@@ -30,4 +30,3 @@ export * from "./dataurl.js";export * from "./tab-session-history.js";export * from "./keybindings.js";export * from "./is-feature-available.js";-export * from "./format-group-title.js";diff --git a/packages/common/src/utils/is-feature-available.ts b/packages/common/src/utils/is-feature-available.tsindex 86de7c672..c3283ad47 100644--- a/packages/common/src/utils/is-feature-available.ts+++ b/packages/common/src/utils/is-feature-available.ts@@ -58,47 +58,28 @@ type CaptionsFromAvailability<A> = A extends Record<? C: never;-const FEATURE_TITLES: Partial<Record<string, () => string>> = {- storage: strings.storage,- fileSize: strings.maximumFileSize,- fullQualityImages: strings.fullQualityImages,- blockLinking: strings.blockLevelNoteLinks,- colors: strings.colors,- tags: strings.tags,- notebooks: strings.notebooks,- activeReminders: strings.activeReminders,- shortcuts: strings.shortcuts,- appLock: strings.appLock,- maxNoteVersions: strings.noteHistory,- customizableSidebar: strings.customizableSidebar,- syncControls: strings.sync,- callout: strings.callout,- sms2FA: strings.twoFactorAuth,- monographs: strings.monographs-};-function createFeature<A extends FeatureAvailability>(feature: Omit<Feature, "error" | "availability"> & {error?: Feature["error"];availability: A;}): Feature<CaptionsFromAvailability<A>> {- const getTitle = (): string => {- const localized = FEATURE_TITLES[feature.id];- return localized ? localized() : feature.title;- };const f = {...feature,- get title(): string {- return getTitle();- },error:feature.error ??((l: Limit): string =>typeof l.caption === "number"- ? strings.reachedLimitOf(l.caption, getTitle().toLowerCase())- : strings.featureNotAvailableOnPlan(getTitle()))+ ? strings.reachedLimitOf(l.caption, feature.title.toLowerCase())+ : strings.featureNotAvailableOnPlan(feature.title))};+ Object.defineProperty(f, "title", {+ get() {+ return feature.title;+ },+ enumerable: true,+ configurable: true+ });return f as unknown as Feature<CaptionsFromAvailability<A>>;}@@ -144,7 +125,9 @@ type Caption<TId extends FeatureId> =const features = {storage: createFeature({id: "storage",- title: "Storage",+ get title() {+ return strings.storage();+ },used: async () => {const user = await db.user.getUser();return user?.storageUsed || 0;@@ -159,9 +142,11 @@ const features = {}),fileSize: createFeature({id: "fileSize",- title: "Maximum file size",+ get title() {+ return strings.maximumFileSize();+ },error: (limit) =>- `You cannot upload files larger than ${limit.caption} on this plan.`,+ strings.cannotUploadFilesLargerThan(limit.caption as string | number),availability: {free: createLimit("10MB", 10 * 1024 * 1024),essential: createLimit("100MB", 100 * 1024 * 1024),@@ -172,7 +157,9 @@ const features = {}),fullQualityImages: createFeature({id: "fullQualityImages",- title: "Full quality images",+ get title() {+ return strings.fullQualityImages();+ },availability: {free: createLimit(false),essential: createLimit(false),@@ -183,8 +170,11 @@ const features = {}),blockLinking: createFeature({id: "blockLinking",- title: "Block-level note links",- error: () => `Block-level note links are not available on this plan.`,+ get title() {+ return strings.blockLevelNoteLinks();+ },+ error: () =>+ strings.featureNotAvailableOnPlan(strings.blockLevelNoteLinks()),availability: {free: createLimit(false),essential: createLimit(true),@@ -195,7 +185,9 @@ const features = {}),taskList: createFeature({id: "taskList",- title: "Task list",+ get title() {+ return strings.taskList();+ },availability: {free: createLimit(false),essential: createLimit(true),@@ -206,7 +198,9 @@ const features = {}),outlineList: createFeature({id: "outlineList",- title: "Outline list",+ get title() {+ return strings.outlineList();+ },availability: {free: createLimit(false),essential: createLimit(true),@@ -217,7 +211,9 @@ const features = {}),callout: createFeature({id: "callout",- title: "Callouts",+ get title() {+ return strings.callout();+ },availability: {free: createLimit(false),essential: createLimit(true),@@ -228,7 +224,9 @@ const features = {}),colors: createFeature({id: "colors",- title: "Colors",+ get title() {+ return strings.colors();+ },used: () => db.colors.all.count(),availability: {free: createLimit(7),@@ -240,7 +238,9 @@ const features = {}),tags: createFeature({id: "tags",- title: "Tags",+ get title() {+ return strings.tags();+ },used: () => db.tags.all.count(),availability: {free: createLimit(50),@@ -252,7 +252,9 @@ const features = {}),notebooks: createFeature({id: "notebooks",- title: "Notebooks",+ get title() {+ return strings.notebooks();+ },used: () => db.notebooks.all.count(),availability: {free: createLimit(50),@@ -264,7 +266,9 @@ const features = {}),activeReminders: createFeature({id: "activeReminders",- title: "Active reminders",+ get title() {+ return strings.activeReminders();+ },used: () => db.reminders.active.count(),availability: {free: createLimit(10),@@ -276,7 +280,9 @@ const features = {}),shortcuts: createFeature({id: "shortcuts",- title: "Shortcuts",+ get title() {+ return strings.shortcuts();+ },used: () => db.shortcuts.all.length,availability: {free: createLimit(10),@@ -288,8 +294,10 @@ const features = {}),defaultNotebookAndTag: createFeature({id: "defaultNotebookAndTag",- title: "Default notebook & tag",- error: () => `You cannot set a default notebook or tag on this plan.`,+ get title() {+ return strings.defaultNotebookAndTag();+ },+ error: () => strings.cannotSetDefaultNotebookOrTag(),availability: {free: createLimit(false),essential: createLimit(false),@@ -300,7 +308,9 @@ const features = {}),recurringReminders: createFeature({id: "recurringReminders",- title: "Recurring reminders",+ get title() {+ return strings.recurringReminders();+ },availability: {free: createLimit(false),essential: createLimit(true),@@ -311,7 +321,9 @@ const features = {}),pinNoteInNotification: createFeature({id: "pinNoteInNotification",- title: "Pin note in notification",+ get title() {+ return strings.pinNoteInNotification();+ },availability: {free: createLimit(false),essential: createLimit(false),@@ -322,7 +334,9 @@ const features = {}),createNoteFromNotificationDrawer: createFeature({id: "createNoteFromNotificationDrawer",- title: "Create note from notification drawer",+ get title() {+ return strings.createNoteFromNotificationDrawer();+ },availability: {free: createLimit(false),essential: createLimit(false),@@ -333,7 +347,9 @@ const features = {}),defaultSidebarTab: createFeature({id: "defaultSidebarTab",- title: "Default sidebar tab",+ get title() {+ return strings.defaultSidebarTab();+ },availability: {free: createLimit(false),essential: createLimit(false),@@ -344,7 +360,9 @@ const features = {}),customHomepage: createFeature({id: "customHomepage",- title: "Custom homepage",+ get title() {+ return strings.customHomepage();+ },availability: {free: createLimit(false),essential: createLimit(false),@@ -355,7 +373,9 @@ const features = {}),markdownShortcuts: createFeature({id: "markdownShortcuts",- title: "Markdown shortcuts",+ get title() {+ return strings.mardownShortcuts();+ },availability: {free: createLimit(false),essential: createLimit(true),@@ -366,7 +386,9 @@ const features = {}),fontLigatures: createFeature({id: "fontLigatures",- title: "Font ligatures",+ get title() {+ return strings.fontLigatures();+ },availability: {free: createLimit(false),essential: createLimit(false),@@ -377,7 +399,9 @@ const features = {}),customToolbarPreset: createFeature({id: "customToolbarPreset",- title: "Custom toolbar preset",+ get title() {+ return strings.customToolbarPreset();+ },availability: {free: createLimit(false),essential: createLimit(false),@@ -388,7 +412,9 @@ const features = {}),customizableSidebar: createFeature({id: "customizableSidebar",- title: "Customizable sidebar",+ get title() {+ return strings.customizableSidebar();+ },availability: {free: createLimit(false),essential: createLimit(true),@@ -399,7 +425,9 @@ const features = {}),disableTrashCleanup: createFeature({id: "disableTrashCleanup",- title: "Disable trash cleanup",+ get title() {+ return strings.disableTrashCleanup();+ },availability: {free: createLimit(false),essential: createLimit(false),@@ -410,7 +438,9 @@ const features = {}),appLock: createFeature({id: "appLock",- title: "App lock",+ get title() {+ return strings.appLock();+ },availability: {free: createLimit(false),essential: createLimit(false),@@ -421,7 +451,9 @@ const features = {}),maxNoteVersions: createFeature({id: "maxNoteVersions",- title: "Maximum note versions",+ get title() {+ return strings.noteHistory();+ },availability: {free: createLimit(100),essential: createLimit(1000),@@ -432,7 +464,9 @@ const features = {}),fullOfflineMode: createFeature({id: "fullOfflineMode",- title: "Full offline mode",+ get title() {+ return strings.fullOfflineMode();+ },availability: {free: createLimit(false),essential: createLimit(true),@@ -443,7 +477,9 @@ const features = {}),syncControls: createFeature({id: "syncControls",- title: "Sync controls",+ get title() {+ return strings.sync();+ },availability: {free: createLimit(false),essential: createLimit(false),@@ -454,7 +490,9 @@ const features = {}),monographLinksAndEmbeds: createFeature({id: "monographLinksAndEmbeds",- title: "Links & embeds in monographs",+ get title() {+ return strings.monographLinksAndEmbeds();+ },availability: {free: createLimit(false),essential: createLimit(true),@@ -465,7 +503,9 @@ const features = {}),monographAnalytics: createFeature({id: "monographAnalytics",- title: "Monographs analytics",+ get title() {+ return strings.monographAnalytics();+ },availability: {free: createLimit(false),essential: createLimit(false),@@ -476,7 +516,9 @@ const features = {}),sms2FA: createFeature({id: "sms2FA",- title: "2FA via SMS",+ get title() {+ return strings.twoFactorAuth();+ },availability: {free: createLimit(false),essential: createLimit(false),@@ -487,7 +529,9 @@ const features = {}),notesnookCircle: createFeature({id: "notesnookCircle",- title: "Notesnook Circle",+ get title() {+ return strings.notesnookCircle();+ },availability: {free: createLimit(false),essential: createLimit(true),@@ -498,7 +542,9 @@ const features = {}),androidLauncherShortcuts: createFeature({id: "androidLauncherShortcuts",- title: "Android Launcher Shortcuts",+ get title() {+ return strings.androidLauncherShortcuts();+ },availability: {free: createLimit(false),essential: createLimit(false),@@ -509,7 +555,9 @@ const features = {}),expiringNotes: createFeature({id: "expiringNotes",- title: "Expiring notes",+ get title() {+ return strings.expiringNotes();+ },availability: {free: createLimit(false),essential: createLimit(false),@@ -520,7 +568,9 @@ const features = {}),exportTableAsCsv: createFeature({id: "exportTableAsCsv",- title: "Export table as CSV",+ get title() {+ return strings.exportTableAsCsv();+ },availability: {free: createLimit(false),essential: createLimit(false),@@ -531,7 +581,9 @@ const features = {}),importCsvToTable: createFeature({id: "importCsvToTable",- title: "Import CSV to table",+ get title() {+ return strings.importCsvToTable();+ },availability: {free: createLimit(false),essential: createLimit(false),diff --git a/packages/core/__tests__/setup/test.setup.ts b/packages/core/__tests__/setup/test.setup.tsindex 0dc03351e..b15b76785 100644--- a/packages/core/__tests__/setup/test.setup.ts+++ b/packages/core/__tests__/setup/test.setup.ts@@ -21,6 +21,9 @@ import "isomorphic-fetch";import dotenv from "dotenv";import { DOMParser } from "linkedom";import WebSocket from "ws";+import { initLocaleSync } from "@notesnook/intl";++initLocaleSync({ systemLocale: "en" });// eslint-disable-next-line @typescript-eslint/ban-ts-comment// @ts-ignorediff --git a/packages/core/src/collections/reminders.ts b/packages/core/src/collections/reminders.tsindex f642287f5..d718e2884 100644--- a/packages/core/src/collections/reminders.ts+++ b/packages/core/src/collections/reminders.ts@@ -30,6 +30,7 @@ import Database from "../api/index.js";import { SQLCollection } from "../database/sql-collection.js";import { isFalse } from "../database/index.js";import { sql } from "@streetwriters/kysely";+import { strings } from "@notesnook/intl";dayjs.extend(isTomorrow);dayjs.extend(isSameOrBefore);@@ -135,13 +136,15 @@ export function formatReminderTime(let tag = "";let text = "";- if (reminder.mode === "permanent") return `Ongoing`;+ if (reminder.mode === "permanent") return strings.ongoing();if (reminder.snoozeUntil && reminder.snoozeUntil > Date.now()) {- return `Snoozed until ${formatDate(reminder.snoozeUntil, {- timeFormat: options.timeFormat,- type: "time"- })}`;+ return strings.snoozedUntil(+ formatDate(reminder.snoozeUntil, {+ timeFormat: options.timeFormat,+ type: "time"+ })+ );}if (reminder.mode === "repeat") {@@ -160,16 +163,16 @@ export function formatReminderTime(});if (dayjs(time).isTomorrow()) {- tag = "Upcoming";- text = `Tomorrow, ${formattedTime}`;+ tag = strings.upcoming();+ text = `${strings.tomorrow()}, ${formattedTime}`;} else if (dayjs(time).isYesterday()) {- tag = "Last";- text = `Yesterday, ${formattedTime}`;+ tag = strings.last();+ text = `${strings.yesterday()}, ${formattedTime}`;} else {const isPast = dayjs(time).isSameOrBefore(dayjs());- tag = isPast ? "Last" : "Upcoming";+ tag = isPast ? strings.last() : strings.upcoming();if (dayjs(time).isToday()) {- text = `Today, ${formattedTime}`;+ text = `${strings.today()}, ${formattedTime}`;} else {text = formattedDateTime;}diff --git a/packages/core/src/utils/date.ts b/packages/core/src/utils/date.tsindex d81a16413..e9b59956a 100644--- a/packages/core/src/utils/date.ts+++ b/packages/core/src/utils/date.ts@@ -21,20 +21,44 @@ import dayjs from "dayjs";import advancedFormat from "dayjs/plugin/advancedFormat.js";import timezone from "dayjs/plugin/timezone.js";import { TimeFormat, DayFormat } from "../types.js";+import { i18n } from "@notesnook/intl";dayjs.extend(advancedFormat);dayjs.extend(timezone);-export function getWeekGroupFromTimestamp(timestamp: number) {+function formatShortMonth(month: number, year: number, locale?: string): string {+ try {+ const str = new Intl.DateTimeFormat(locale || i18n.locale || undefined, {+ month: "short"+ }).format(new Date(year, month, 1));+ return str.charAt(0).toUpperCase() + str.slice(1);+ } catch {+ return MONTHS_SHORT[month];+ }+}++export function formatMonthGroup(date: Date, locale?: string): string {+ try {+ const formatted = new Intl.DateTimeFormat(locale || i18n.locale || undefined, {+ month: "long",+ year: "numeric"+ }).format(date);+ return formatted.charAt(0).toUpperCase() + formatted.slice(1);+ } catch {+ return `${MONTHS_FULL[date.getMonth()]} ${date.getFullYear()}`;+ }+}++export function getWeekGroupFromTimestamp(timestamp: number, locale?: string) {const date = new Date(timestamp);const { start, end } = getWeek(date);const startMonth =- start.month !== end.month ? " " + MONTHS_SHORT[start.month] : "";+ start.month !== end.month ? " " + formatShortMonth(start.month, start.year, locale) : "";const startYear = start.year !== end.year ? ", " + start.year : "";const startDate = `${start.day}${startMonth}${startYear}`;- const endDate = `${end.day} ${MONTHS_SHORT[end.month]}, ${end.year}`;+ const endDate = `${end.day} ${formatShortMonth(end.month, end.year, locale)}, ${end.year}`;return `${startDate} - ${endDate}`;}diff --git a/packages/core/src/utils/grouping.ts b/packages/core/src/utils/grouping.tsindex 2e84029c4..ae780f02c 100644--- a/packages/core/src/utils/grouping.ts+++ b/packages/core/src/utils/grouping.ts@@ -25,7 +25,8 @@ import {Reminder,SortOptions} from "../types.js";-import { getWeekGroupFromTimestamp, MONTHS_FULL } from "../utils/date.js";+import { formatMonthGroup, getWeekGroupFromTimestamp } from "../utils/date.js";+import { strings } from "@notesnook/intl";type PartialGroupableItem = {id: string;@@ -86,22 +87,25 @@ export function createKeySelector(}): GroupKeySelectorFunction<PartialGroupableItem> {return (item) => {- if ("pinned" in item && item.pinned) return "Pinned";- else if ("conflicted" in item && item.conflicted) return "Conflicted";+ if ("pinned" in item && item.pinned) return strings.pinned();+ else if ("conflicted" in item && item.conflicted)+ return strings.conflicted();const date = new Date();if (item.type === "reminder")- return isReminderActive(item as Reminder) ? "Active" : "Inactive";+ return isReminderActive(item as Reminder)+ ? strings.active()+ : strings.inactive();else if (options.groupBy === "abc")return getFirstCharacter(getTitle(item));else {const value = getSortValue(options, item) || 0;switch (options.groupBy) {case "none":- return "All";+ return strings.all();case "month":date.setTime(value);- return `${MONTHS_FULL[date.getMonth()]} ${date.getFullYear()}`;+ return formatMonthGroup(date);case "week":return getWeekGroupFromTimestamp(value);case "year":@@ -110,10 +114,10 @@ export function createKeySelector(case "default":default: {return value > date.getTime() - MILLISECONDS_IN_WEEK- ? "Recent"+ ? strings.recent(): value > date.getTime() - MILLISECONDS_IN_WEEK * 2- ? "Last week"- : "Older";+ ? strings.lastWeek()+ : strings.older();}}}@@ -138,7 +142,13 @@ export function groupArray<T>(i,{index: i,- group: { id: groupTitle, title: groupTitle, type: "header" }+ group: {+ id: groupTitle,+ get title() {+ return keySelector(item);+ },+ type: "header"+ }}]);}@@ -153,5 +163,5 @@ function getFirstCharacter(str: string) {}function getTitle(item: PartialGroupableItem): string {- return ("filename" in item ? item.filename : item.title) || "Unknown";+ return ("filename" in item ? item.filename : item.title) || strings.unknown();}diff --git a/packages/intl/src/setup.ts b/packages/intl/src/setup.tsindex c76d4a31f..92ef5234b 100644--- a/packages/intl/src/setup.ts+++ b/packages/intl/src/setup.ts@@ -18,19 +18,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import { I18n, i18n as i18nn } from "@lingui/core";-let i18nGlobal: I18n | undefined = undefined;+const GLOBAL_I18N_KEY = "__notesnook_i18n__";export const setI18nGlobal = (newI18n: any) => {if (newI18n === i18n) return;- i18nGlobal = newI18n;+ (globalThis as any)[GLOBAL_I18N_KEY] = newI18n;};export function getI18nGlobal() {- return i18nGlobal;+ return (globalThis as any)[GLOBAL_I18N_KEY];}export const i18n: I18n = new Proxy({} as I18n, {get: (target, property) => {- const active = i18nGlobal || i18nn;+ const active = (globalThis as any)[GLOBAL_I18N_KEY] || i18nn;const value = active[property as keyof I18n];if (typeof value === "function") {return value.bind(active);