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:
@ -6,6 +6,7 @@ import * as api from "@/helpers/api";
|
||||
import { generateDialog } from "./Dialog";
|
||||
import Icon from "./Icon";
|
||||
import LearnMore from "./LearnMore";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
interface Props extends DialogProps {
|
||||
localStoragePath?: string;
|
||||
@ -13,6 +14,7 @@ interface Props extends DialogProps {
|
||||
}
|
||||
|
||||
const UpdateLocalStorageDialog: React.FC<Props> = (props: Props) => {
|
||||
const { t } = useTranslation();
|
||||
const { destroy, localStoragePath, confirmCallback } = props;
|
||||
const globalStore = useGlobalStore();
|
||||
const [path, setPath] = useState(localStoragePath || "");
|
||||
@ -41,23 +43,31 @@ const UpdateLocalStorageDialog: React.FC<Props> = (props: Props) => {
|
||||
return (
|
||||
<>
|
||||
<div className="dialog-header-container">
|
||||
<p className="title-text">Update local storage path</p>
|
||||
<p className="title-text">{t("setting.storage-section.update-local-path")}</p>
|
||||
<button className="btn close-btn" onClick={handleCloseBtnClick}>
|
||||
<Icon.X />
|
||||
</button>
|
||||
</div>
|
||||
<div className="dialog-content-container max-w-xs">
|
||||
<p className="text-sm break-words mb-1">
|
||||
{"Local storage path is a relative path to your database file."}
|
||||
{t("setting.storage-section.update-local-path-description")}
|
||||
<LearnMore className="ml-1" url="https://usememos.com/docs/local-storage" />
|
||||
</p>
|
||||
<p className="text-sm text-gray-400 mb-2 break-all">{"e.g. assets/{timestamp}_{filename}"}</p>
|
||||
<Input className="mb-2" placeholder="Local storage path" fullWidth value={path} onChange={(e) => setPath(e.target.value)} />
|
||||
<p className="text-sm text-gray-400 mb-2 break-all">
|
||||
{t("common.e.g")} {"assets/{timestamp}_{filename}"}
|
||||
</p>
|
||||
<Input
|
||||
className="mb-2"
|
||||
placeholder={t("setting.storage-section.local-storage-path")}
|
||||
fullWidth
|
||||
value={path}
|
||||
onChange={(e) => setPath(e.target.value)}
|
||||
/>
|
||||
<div className="mt-2 w-full flex flex-row justify-end items-center space-x-1">
|
||||
<Button variant="plain" color="neutral" onClick={handleCloseBtnClick}>
|
||||
Cancel
|
||||
{t("common.cancel")}
|
||||
</Button>
|
||||
<Button onClick={handleConfirmBtnClick}>Update</Button>
|
||||
<Button onClick={handleConfirmBtnClick}>{t("common.update")}</Button>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
|
Reference in New Issue
Block a user