mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
feat: improve i18n support as a whole (#1526)
* feat: improve i18n support as a whole - Remove dayjs in favor of /helpers/datetime.ts, which uses Intl.DateTimeFormat and Date. Dayjs is not exactly i18n friendly and has several locale related opened issues. - Move/refactor date/time code from /helpers/utils.ts to /helpers/datetime.ts. - Fix Daily Review weekday not changing according to selected date. - Localize Daily review weekday and month. - Load i18n listed strings from /locales/{locale}.json in a dynamic way. This makes much easier to add new locales, by just adding a properly named json file and listing it only in /web/src/i18n.ts and /api/user_setting.go. - Fallback languages are now set in /web/src/i18n.ts. - Full language codes are now preffered, but they fallback to 2-letter codes when not available. - The locale dropdown is now populated dynamically from the available locales. Locale names are populated by the browser via Intl.DisplayNames(locale). - /web/src/i18n.ts now exports a type TLocale from availableLocales array. This is used only by findNearestLanguageMatch(). As I was unable to use this type in ".d.ts" files, I switched the Locale type from /web/src/types/i18n.d.ts to string. - Move pretty much all hardcoded text strings to i18n strings. - Add pt-BR translation. - Remove site.ts and move its content to a i18n string. - Rename zh.json to zh-Hans.json to get the correct language name on selector dropdown. - Remove pt_BR.json and replace with pt-BR.json. - Some minor layout spacing fixes to accommodate larger texts. - Improve some error messages. * Delete .yarnrc.yml * Delete package-lock.json * fix: 158:28 error Insert `⏎` prettier/prettier
This commit is contained in:
@ -39,7 +39,7 @@ const StorageSection = () => {
|
||||
const handleDeleteStorage = (storage: ObjectStorage) => {
|
||||
showCommonDialog({
|
||||
title: t("setting.storage-section.delete-storage"),
|
||||
content: t("setting.storage-section.warning-text"),
|
||||
content: t("setting.storage-section.warning-text", { name: storage.name }),
|
||||
style: "warning",
|
||||
dialogName: "delete-storage-dialog",
|
||||
onConfirm: async () => {
|
||||
@ -57,7 +57,7 @@ const StorageSection = () => {
|
||||
return (
|
||||
<div className="section-container">
|
||||
<div className="mt-4 mb-2 w-full flex flex-row justify-start items-center">
|
||||
<span className="font-mono text-sm text-gray-400 mr-2">Current storage</span>
|
||||
<span className="font-mono text-sm text-gray-400 mr-2">{t("setting.storage-section.current-storage")}</span>
|
||||
</div>
|
||||
<Select
|
||||
className="w-full mb-4"
|
||||
@ -66,8 +66,8 @@ const StorageSection = () => {
|
||||
handleActiveStorageServiceChanged(storageId ?? storageServiceId);
|
||||
}}
|
||||
>
|
||||
<Option value={0}>Database</Option>
|
||||
<Option value={-1}>Local</Option>
|
||||
<Option value={0}>{t("setting.storage-section.type-database")}</Option>
|
||||
<Option value={-1}>{t("setting.storage-section.type-local")}</Option>
|
||||
{storageList.map((storage) => (
|
||||
<Option key={storage.id} value={storage.id}>
|
||||
{storage.name}
|
||||
@ -84,7 +84,7 @@ const StorageSection = () => {
|
||||
<div className="mt-2 w-full flex flex-col">
|
||||
<div className="py-2 w-full border-t dark:border-zinc-700 flex flex-row items-center justify-between">
|
||||
<div className="flex flex-row items-center">
|
||||
<p className="ml-2">Local</p>
|
||||
<p className="ml-2">{t("setting.storage-section.type-local")}</p>
|
||||
</div>
|
||||
<div className="flex flex-row items-center">
|
||||
<Dropdown
|
||||
@ -95,7 +95,7 @@ const StorageSection = () => {
|
||||
className="w-full text-left text-sm leading-6 py-1 px-3 cursor-pointer rounded hover:bg-gray-100 dark:hover:bg-zinc-600"
|
||||
onClick={() => showUpdateLocalStorageDialog(systemStatus.localStoragePath)}
|
||||
>
|
||||
Edit
|
||||
{t("common.edit")}
|
||||
</button>
|
||||
</>
|
||||
}
|
||||
@ -119,7 +119,7 @@ const StorageSection = () => {
|
||||
className="w-full text-left text-sm leading-6 py-1 px-3 cursor-pointer rounded hover:bg-gray-100 dark:hover:bg-zinc-600"
|
||||
onClick={() => showCreateStorageServiceDialog(storage, fetchStorageList)}
|
||||
>
|
||||
Edit
|
||||
{t("common.edit")}
|
||||
</button>
|
||||
<button
|
||||
className="w-full text-left text-sm leading-6 py-1 px-3 cursor-pointer rounded text-red-600 hover:bg-gray-100 dark:hover:bg-zinc-600"
|
||||
|
Reference in New Issue
Block a user