From 5eec6351465e77042899e7008475b8748d2e8bbf Mon Sep 17 00:00:00 2001 From: MaysWind Date: Sat, 4 Jan 2025 18:52:21 +0800 Subject: [PATCH] migrate snack bar to composition API and typescript --- src/components/desktop/SnackBar.vue | 67 +++++++++++++---------------- src/lib/i18n.js | 11 ++++- 2 files changed, 40 insertions(+), 38 deletions(-) diff --git a/src/components/desktop/SnackBar.vue b/src/components/desktop/SnackBar.vue index 48300d7c..1da95b0f 100644 --- a/src/components/desktop/SnackBar.vue +++ b/src/components/desktop/SnackBar.vue @@ -8,43 +8,36 @@ - diff --git a/src/lib/i18n.js b/src/lib/i18n.js index 67ccf40d..b26c58fd 100644 --- a/src/lib/i18n.js +++ b/src/lib/i18n.js @@ -1,8 +1,9 @@ +import { useI18n as useVueI18n } from 'vue-i18n'; import moment from 'moment-timezone'; import { defaultLanguage, allLanguages } from '@/locales/index.ts'; -import { Month, WeekDay, MeridiemIndicator, LongDateFormat, ShortDateFormat, LongTimeFormat, ShortTimeFormat, DateRangeScene, DateRange, LANGUAGE_DEFAULT_DATE_TIME_FORMAT_VALUE } from '@/core/datetime.ts'; +import { Month, WeekDay, MeridiemIndicator, LongDateFormat, ShortDateFormat, LongTimeFormat, ShortTimeFormat, DateRange, LANGUAGE_DEFAULT_DATE_TIME_FORMAT_VALUE } from '@/core/datetime.ts'; import { TimezoneTypeForStatistics } from '@/core/timezone.ts'; import { DecimalSeparator, DigitGroupingSymbol, DigitGroupingType } from '@/core/numeral.ts'; import { CurrencyDisplayType, CurrencySortingType } from '@/core/currency.ts'; @@ -1747,8 +1748,16 @@ export function i18nFunctions(i18nGlobal) { getCategorizedAccountsWithDisplayBalance: (allVisibleAccounts, showAccountBalance, defaultCurrency, settingsStore, userStore, exchangeRatesStore) => getCategorizedAccountsWithDisplayBalance(allVisibleAccounts, showAccountBalance, defaultCurrency, userStore, settingsStore, exchangeRatesStore, i18nGlobal.t), getServerTipContent: (tipConfig) => getServerTipContent(tipConfig, i18nGlobal), joinMultiText: (textArray) => joinMultiText(textArray, i18nGlobal.t), + tt: (...args) => i18nGlobal.t(...args), + ti: (text, isTranslate) => translateIf(text, isTranslate, i18nGlobal.t), + te: (message) => translateError(message, i18nGlobal.t), setLanguage: (locale, force) => setLanguage(i18nGlobal, locale, force), setTimeZone: (timezone) => setTimeZone(timezone), initLocale: (lastUserLanguage, timezone) => initLocale(i18nGlobal, lastUserLanguage, timezone) }; } + +export function useI18n() { + const i18nGlobal = useVueI18n(); + return i18nFunctions(i18nGlobal); +}