mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 09:14:27 +08:00
fix the locale settings on the profile page does not immediately update the preview
This commit is contained in:
+69
-60
@@ -777,8 +777,10 @@ export function useI18n() {
|
|||||||
format = FiscalYearFormat.Default;
|
format = FiscalYearFormat.Default;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isDefined(calendarType) || !isGregorianLikeCalendarType(calendarType)) {
|
if (!isDefined(calendarType)) {
|
||||||
calendarType = getGregorianLikeCalendarType();
|
calendarType = getGregorianLikeCalendarType();
|
||||||
|
} else if (!isGregorianLikeCalendarType(calendarType)) {
|
||||||
|
calendarType = CalendarType.Gregorian;
|
||||||
}
|
}
|
||||||
|
|
||||||
const dateTimeFormatOptions = getDateTimeFormatOptions({
|
const dateTimeFormatOptions = getDateTimeFormatOptions({
|
||||||
@@ -1611,109 +1613,109 @@ export function useI18n() {
|
|||||||
return numeralSystem.getAllDigits();
|
return numeralSystem.getAllDigits();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCurrentCalendarDisplayType(): CalendarDisplayType {
|
function getLocaleDefaultCalendarDisplayType(): CalendarDisplayType {
|
||||||
let calendarDisplayType = CalendarDisplayType.valueOf(userStore.currentUserCalendarDisplayType);
|
const defaultCalendarDisplayTypeName = t('default.calendarDisplayType');
|
||||||
|
let calendarDisplayType = CalendarDisplayType.parse(defaultCalendarDisplayTypeName);
|
||||||
|
|
||||||
if (!calendarDisplayType) {
|
if (!calendarDisplayType) {
|
||||||
const defaultCalendarDisplayTypeName = t('default.calendarDisplayType');
|
calendarDisplayType = CalendarDisplayType.Default;
|
||||||
calendarDisplayType = CalendarDisplayType.parse(defaultCalendarDisplayTypeName);
|
|
||||||
|
|
||||||
if (!calendarDisplayType) {
|
|
||||||
calendarDisplayType = CalendarDisplayType.Default;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return calendarDisplayType;
|
return calendarDisplayType;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCurrentDateDisplayType(): DateDisplayType {
|
function getLocaleDefaultDateDisplayType(): DateDisplayType {
|
||||||
let dateDisplayType = DateDisplayType.valueOf(userStore.currentUserDateDisplayType);
|
const defaultDateDisplayTypeName = t('default.dateDisplayType');
|
||||||
|
let dateDisplayType = DateDisplayType.parse(defaultDateDisplayTypeName);
|
||||||
|
|
||||||
if (!dateDisplayType) {
|
if (!dateDisplayType) {
|
||||||
const defaultDateDisplayTypeName = t('default.dateDisplayType');
|
dateDisplayType = DateDisplayType.Default;
|
||||||
dateDisplayType = DateDisplayType.parse(defaultDateDisplayTypeName);
|
|
||||||
|
|
||||||
if (!dateDisplayType) {
|
|
||||||
dateDisplayType = DateDisplayType.Default;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return dateDisplayType;
|
return dateDisplayType;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCurrentNumeralSystemType(): NumeralSystem {
|
function getLocaleDefaultNumeralSystemType(): NumeralSystem {
|
||||||
let numeralSystemType = NumeralSystem.valueOf(userStore.currentUserNumeralSystem);
|
const defaultNumeralSystemTypeName = t('default.numeralSystem');
|
||||||
|
let numeralSystemType = NumeralSystem.parse(defaultNumeralSystemTypeName);
|
||||||
|
|
||||||
if (!numeralSystemType) {
|
if (!numeralSystemType) {
|
||||||
const defaultNumeralSystemTypeName = t('default.numeralSystem');
|
numeralSystemType = NumeralSystem.Default;
|
||||||
numeralSystemType = NumeralSystem.parse(defaultNumeralSystemTypeName);
|
|
||||||
|
|
||||||
if (!numeralSystemType) {
|
|
||||||
numeralSystemType = NumeralSystem.Default;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return numeralSystemType;
|
return numeralSystemType;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCurrentDecimalSeparator(): string {
|
function getLocaleDefaultDecimalSeparator(): DecimalSeparator {
|
||||||
let decimalSeparatorType = DecimalSeparator.valueOf(userStore.currentUserDecimalSeparator);
|
const defaultDecimalSeparatorTypeName = t('default.decimalSeparator');
|
||||||
|
let decimalSeparatorType = DecimalSeparator.parse(defaultDecimalSeparatorTypeName);
|
||||||
|
|
||||||
if (!decimalSeparatorType) {
|
if (!decimalSeparatorType) {
|
||||||
const defaultDecimalSeparatorTypeName = t('default.decimalSeparator');
|
decimalSeparatorType = DecimalSeparator.Default;
|
||||||
decimalSeparatorType = DecimalSeparator.parse(defaultDecimalSeparatorTypeName);
|
|
||||||
|
|
||||||
if (!decimalSeparatorType) {
|
|
||||||
decimalSeparatorType = DecimalSeparator.Default;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return decimalSeparatorType.symbol;
|
return decimalSeparatorType;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCurrentDigitGroupingSymbol(): string {
|
function getLocaleDefaultDigitGroupingSymbol(): DigitGroupingSymbol {
|
||||||
let digitGroupingSymbolType = DigitGroupingSymbol.valueOf(userStore.currentUserDigitGroupingSymbol);
|
const defaultDigitGroupingSymbolTypeName = t('default.digitGroupingSymbol');
|
||||||
|
let digitGroupingSymbolType = DigitGroupingSymbol.parse(defaultDigitGroupingSymbolTypeName);
|
||||||
|
|
||||||
if (!digitGroupingSymbolType) {
|
if (!digitGroupingSymbolType) {
|
||||||
const defaultDigitGroupingSymbolTypeName = t('default.digitGroupingSymbol');
|
digitGroupingSymbolType = DigitGroupingSymbol.Default;
|
||||||
digitGroupingSymbolType = DigitGroupingSymbol.parse(defaultDigitGroupingSymbolTypeName);
|
|
||||||
|
|
||||||
if (!digitGroupingSymbolType) {
|
|
||||||
digitGroupingSymbolType = DigitGroupingSymbol.Default;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return digitGroupingSymbolType.symbol;
|
return digitGroupingSymbolType;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCurrentDigitGroupingType(): DigitGroupingType {
|
function getLocaleDefaultDigitGroupingType(): DigitGroupingType {
|
||||||
let digitGroupingType = DigitGroupingType.valueOf(userStore.currentUserDigitGrouping);
|
const defaultDigitGroupingTypeName = t('default.digitGrouping');
|
||||||
|
let digitGroupingType = DigitGroupingType.parse(defaultDigitGroupingTypeName);
|
||||||
|
|
||||||
if (!digitGroupingType) {
|
if (!digitGroupingType) {
|
||||||
const defaultDigitGroupingTypeName = t('default.digitGrouping');
|
digitGroupingType = DigitGroupingType.Default;
|
||||||
digitGroupingType = DigitGroupingType.parse(defaultDigitGroupingTypeName);
|
|
||||||
|
|
||||||
if (!digitGroupingType) {
|
|
||||||
digitGroupingType = DigitGroupingType.Default;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return digitGroupingType;
|
return digitGroupingType;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCurrentFiscalYearFormatType(): number {
|
function getLocaleFiscalYearFormatType(): FiscalYearFormat {
|
||||||
let fiscalYearFormat = FiscalYearFormat.valueOf(userStore.currentUserFiscalYearFormat);
|
const defaultFiscalYearFormatTypeName = t('default.fiscalYearFormat');
|
||||||
|
let fiscalYearFormat = FiscalYearFormat.parse(defaultFiscalYearFormatTypeName);
|
||||||
|
|
||||||
if (!fiscalYearFormat) {
|
if (!fiscalYearFormat) {
|
||||||
const defaultFiscalYearFormatTypeName = t('default.fiscalYearFormat');
|
fiscalYearFormat = FiscalYearFormat.Default;
|
||||||
fiscalYearFormat = FiscalYearFormat.parse(defaultFiscalYearFormatTypeName);
|
|
||||||
|
|
||||||
if (!fiscalYearFormat) {
|
|
||||||
fiscalYearFormat = FiscalYearFormat.Default;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return fiscalYearFormat.type;
|
return fiscalYearFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCurrentCalendarDisplayType(): CalendarDisplayType {
|
||||||
|
return CalendarDisplayType.valueOf(userStore.currentUserCalendarDisplayType) ?? getLocaleDefaultCalendarDisplayType();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCurrentDateDisplayType(): DateDisplayType {
|
||||||
|
return DateDisplayType.valueOf(userStore.currentUserDateDisplayType) ?? getLocaleDefaultDateDisplayType();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCurrentNumeralSystemType(): NumeralSystem {
|
||||||
|
return NumeralSystem.valueOf(userStore.currentUserNumeralSystem) ?? getLocaleDefaultNumeralSystemType();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCurrentDecimalSeparator(): string {
|
||||||
|
return DecimalSeparator.valueOf(userStore.currentUserDecimalSeparator)?.symbol ?? getLocaleDefaultDecimalSeparator().symbol;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCurrentDigitGroupingSymbol(): string {
|
||||||
|
return DigitGroupingSymbol.valueOf(userStore.currentUserDigitGroupingSymbol)?.symbol ?? getLocaleDefaultDigitGroupingSymbol().symbol;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCurrentDigitGroupingType(): DigitGroupingType {
|
||||||
|
return DigitGroupingType.valueOf(userStore.currentUserDigitGrouping) ?? getLocaleDefaultDigitGroupingType();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCurrentFiscalYearFormatType(): number {
|
||||||
|
return FiscalYearFormat.valueOf(userStore.currentUserFiscalYearFormat)?.type ?? getLocaleFiscalYearFormatType().type;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCurrencyName(currencyCode: string): string {
|
function getCurrencyName(currencyCode: string): string {
|
||||||
@@ -2328,6 +2330,13 @@ export function useI18n() {
|
|||||||
getMultiMonthdayShortNames,
|
getMultiMonthdayShortNames,
|
||||||
getMultiWeekdayLongNames,
|
getMultiWeekdayLongNames,
|
||||||
getAllLocalizedDigits,
|
getAllLocalizedDigits,
|
||||||
|
getLocaleDefaultCalendarDisplayType,
|
||||||
|
getLocaleDefaultDateDisplayType,
|
||||||
|
getLocaleDefaultNumeralSystemType,
|
||||||
|
getLocaleDefaultDecimalSeparator,
|
||||||
|
getLocaleDefaultDigitGroupingSymbol,
|
||||||
|
getLocaleDefaultDigitGroupingType,
|
||||||
|
getLocaleFiscalYearFormatType,
|
||||||
getCurrentCalendarDisplayType,
|
getCurrentCalendarDisplayType,
|
||||||
getCurrentDateDisplayType,
|
getCurrentDateDisplayType,
|
||||||
getCurrentNumeralSystemType,
|
getCurrentNumeralSystemType,
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ export function useUserProfilePageBase() {
|
|||||||
getAllExpenseAmountColors,
|
getAllExpenseAmountColors,
|
||||||
getAllIncomeAmountColors,
|
getAllIncomeAmountColors,
|
||||||
getAllTransactionEditScopeTypes,
|
getAllTransactionEditScopeTypes,
|
||||||
|
getLocaleDefaultDateDisplayType,
|
||||||
|
getLocaleDefaultNumeralSystemType,
|
||||||
|
getLocaleDefaultDecimalSeparator,
|
||||||
|
getLocaleDefaultDigitGroupingSymbol,
|
||||||
setLanguage
|
setLanguage
|
||||||
} = useI18n();
|
} = useI18n();
|
||||||
|
|
||||||
@@ -57,22 +61,27 @@ export function useUserProfilePageBase() {
|
|||||||
const resending = ref<boolean>(false);
|
const resending = ref<boolean>(false);
|
||||||
const saving = ref<boolean>(false);
|
const saving = ref<boolean>(false);
|
||||||
|
|
||||||
|
const currentDateDisplayType = computed<DateDisplayType>(() => DateDisplayType.valueOf(newProfile.value.dateDisplayType) ?? getLocaleDefaultDateDisplayType());
|
||||||
|
const currentNumeralSystem = computed<NumeralSystem>(() => NumeralSystem.valueOf(newProfile.value.numeralSystem) ?? getLocaleDefaultNumeralSystemType());
|
||||||
|
const currentDecimalSeparator = computed<string>(() => DecimalSeparator.valueOf(newProfile.value.decimalSeparator)?.symbol ?? getLocaleDefaultDecimalSeparator().symbol);
|
||||||
|
const currentDigitGroupingSymbol = computed<string>(() => DigitGroupingSymbol.valueOf(newProfile.value.digitGroupingSymbol)?.symbol ?? getLocaleDefaultDigitGroupingSymbol().symbol);
|
||||||
|
|
||||||
const allAccounts = computed<Account[]>(() => accountsStore.allPlainAccounts);
|
const allAccounts = computed<Account[]>(() => accountsStore.allPlainAccounts);
|
||||||
const allVisibleAccounts = computed<Account[]>(() => accountsStore.allVisiblePlainAccounts);
|
const allVisibleAccounts = computed<Account[]>(() => accountsStore.allVisiblePlainAccounts);
|
||||||
const allVisibleCategorizedAccounts = computed<CategorizedAccount[]>(() => getCategorizedAccounts(allVisibleAccounts.value));
|
const allVisibleCategorizedAccounts = computed<CategorizedAccount[]>(() => getCategorizedAccounts(allVisibleAccounts.value));
|
||||||
const allWeekDays = computed<TypeAndDisplayName[]>(() => getAllWeekDays());
|
const allWeekDays = computed<TypeAndDisplayName[]>(() => getAllWeekDays());
|
||||||
const allCalendarDisplayTypes = computed<TypeAndDisplayName[]>(() => getAllCalendarDisplayTypes());
|
const allCalendarDisplayTypes = computed<TypeAndDisplayName[]>(() => getAllCalendarDisplayTypes());
|
||||||
const allDateDisplayTypes = computed<TypeAndDisplayName[]>(() => getAllDateDisplayTypes());
|
const allDateDisplayTypes = computed<TypeAndDisplayName[]>(() => getAllDateDisplayTypes());
|
||||||
const allLongDateFormats = computed<TypeAndDisplayName[]>(() => getAllLongDateFormats(NumeralSystem.valueOf(newProfile.value.numeralSystem) ?? NumeralSystem.Default, DateDisplayType.valueOf(newProfile.value.dateDisplayType)?.calendarType || DateDisplayType.Default.calendarType));
|
const allLongDateFormats = computed<TypeAndDisplayName[]>(() => getAllLongDateFormats(currentNumeralSystem.value, currentDateDisplayType.value.calendarType));
|
||||||
const allShortDateFormats = computed<TypeAndDisplayName[]>(() => getAllShortDateFormats(NumeralSystem.valueOf(newProfile.value.numeralSystem) ?? NumeralSystem.Default, DateDisplayType.valueOf(newProfile.value.dateDisplayType)?.calendarType || DateDisplayType.Default.calendarType));
|
const allShortDateFormats = computed<TypeAndDisplayName[]>(() => getAllShortDateFormats(currentNumeralSystem.value, currentDateDisplayType.value.calendarType));
|
||||||
const allLongTimeFormats = computed<TypeAndDisplayName[]>(() => getAllLongTimeFormats(NumeralSystem.valueOf(newProfile.value.numeralSystem) ?? NumeralSystem.Default));
|
const allLongTimeFormats = computed<TypeAndDisplayName[]>(() => getAllLongTimeFormats(currentNumeralSystem.value));
|
||||||
const allShortTimeFormats = computed<TypeAndDisplayName[]>(() => getAllShortTimeFormats(NumeralSystem.valueOf(newProfile.value.numeralSystem) ?? NumeralSystem.Default));
|
const allShortTimeFormats = computed<TypeAndDisplayName[]>(() => getAllShortTimeFormats(currentNumeralSystem.value));
|
||||||
const allFiscalYearFormats = computed<TypeAndDisplayName[]>(() => getAllFiscalYearFormats(NumeralSystem.valueOf(newProfile.value.numeralSystem) ?? NumeralSystem.Default, DateDisplayType.valueOf(newProfile.value.dateDisplayType)?.calendarType || DateDisplayType.Default.calendarType));
|
const allFiscalYearFormats = computed<TypeAndDisplayName[]>(() => getAllFiscalYearFormats(currentNumeralSystem.value, currentDateDisplayType.value.calendarType));
|
||||||
const allCurrencyDisplayTypes = computed<TypeAndDisplayName[]>(() => getAllCurrencyDisplayTypes(NumeralSystem.valueOf(newProfile.value.numeralSystem) ?? NumeralSystem.Default, DecimalSeparator.valueOf(newProfile.value.decimalSeparator)?.symbol || DecimalSeparator.Default.symbol));
|
const allCurrencyDisplayTypes = computed<TypeAndDisplayName[]>(() => getAllCurrencyDisplayTypes(currentNumeralSystem.value, currentDecimalSeparator.value));
|
||||||
const allNumeralSystemTypes = computed<TypeAndDisplayName[]>(() => getAllNumeralSystemTypes());
|
const allNumeralSystemTypes = computed<TypeAndDisplayName[]>(() => getAllNumeralSystemTypes());
|
||||||
const allDecimalSeparators = computed<TypeAndDisplayName[]>(() => getAllDecimalSeparators());
|
const allDecimalSeparators = computed<TypeAndDisplayName[]>(() => getAllDecimalSeparators());
|
||||||
const allDigitGroupingSymbols = computed<TypeAndDisplayName[]>(() => getAllDigitGroupingSymbols());
|
const allDigitGroupingSymbols = computed<TypeAndDisplayName[]>(() => getAllDigitGroupingSymbols());
|
||||||
const allDigitGroupingTypes = computed<LocalizedDigitGroupingType[]>(() => getAllDigitGroupingTypes(NumeralSystem.valueOf(newProfile.value.numeralSystem) ?? NumeralSystem.Default, DigitGroupingSymbol.valueOf(newProfile.value.digitGroupingSymbol)?.symbol || DigitGroupingSymbol.Default.symbol));
|
const allDigitGroupingTypes = computed<LocalizedDigitGroupingType[]>(() => getAllDigitGroupingTypes(currentNumeralSystem.value, currentDigitGroupingSymbol.value));
|
||||||
const allCoordinateDisplayTypes = computed<TypeAndDisplayName[]>(() => getAllCoordinateDisplayTypes());
|
const allCoordinateDisplayTypes = computed<TypeAndDisplayName[]>(() => getAllCoordinateDisplayTypes());
|
||||||
const allExpenseAmountColorTypes = computed<TypeAndDisplayName[]>(() => getAllExpenseAmountColors());
|
const allExpenseAmountColorTypes = computed<TypeAndDisplayName[]>(() => getAllExpenseAmountColors());
|
||||||
const allIncomeAmountColorTypes = computed<TypeAndDisplayName[]>(() => getAllIncomeAmountColors());
|
const allIncomeAmountColorTypes = computed<TypeAndDisplayName[]>(() => getAllIncomeAmountColors());
|
||||||
|
|||||||
Reference in New Issue
Block a user