show import file type by categories

This commit is contained in:
MaysWind
2025-08-23 02:25:24 +08:00
parent 06a0501633
commit 81727d3b1e
17 changed files with 506 additions and 351 deletions
+8
View File
@@ -1727,9 +1727,17 @@
"Check and Modify Your Data": "Überprüfen und Ändern Sie Ihre Daten",
"Data Import Completed": "Datenimport abgeschlossen",
"File Type": "Dateityp",
"Find file type": "Find file type",
"No available file type": "No available file type",
"Filter Description": "Filterbeschreibung",
"How to import this file?": "How to import this file?",
"How to export this file?": "Wie exportiere ich diese Datei?",
"ezBookkeeping File Format": "ezBookkeeping File Format",
"Custom File Format": "Custom File Format",
"General Data Exchange Format": "General Data Exchange Format",
"General Bank Statement Format": "General Bank Statement Format",
"Other Bank/Payment App Statement File": "Other Bank/Payment App Statement File",
"Other Finance App File Format": "Other Finance App File Format",
"ezbookkeeping Data Export File": "ezBookkeeping-Datenexportdatei",
"Excel Workbook File": "Excel Workbook File",
"Open Financial Exchange (OFX) File": "Open Financial Exchange (OFX)-Datei",
+8
View File
@@ -1727,9 +1727,17 @@
"Check and Modify Your Data": "Check and Modify Your Data",
"Data Import Completed": "Data Import Completed",
"File Type": "File Type",
"Find file type": "Find file type",
"No available file type": "No available file type",
"Filter Description": "Filter Description",
"How to import this file?": "How to import this file?",
"How to export this file?": "How to export this file?",
"ezBookkeeping File Format": "ezBookkeeping File Format",
"Custom File Format": "Custom File Format",
"General Data Exchange Format": "General Data Exchange Format",
"General Bank Statement Format": "General Bank Statement Format",
"Other Bank/Payment App Statement File": "Other Bank/Payment App Statement File",
"Other Finance App File Format": "Other Finance App File Format",
"ezbookkeeping Data Export File": "ezbookkeeping Data Export File",
"Excel Workbook File": "Excel Workbook File",
"Open Financial Exchange (OFX) File": "Open Financial Exchange (OFX) File",
+8
View File
@@ -1727,9 +1727,17 @@
"Check and Modify Your Data": "Verifique y modifique sus datos",
"Data Import Completed": "Importación de datos completada",
"File Type": "Tipo de archivo",
"Find file type": "Find file type",
"No available file type": "No available file type",
"Filter Description": "Descripción del filtro",
"How to import this file?": "How to import this file?",
"How to export this file?": "¿Cómo exportar este archivo?",
"ezBookkeeping File Format": "ezBookkeeping File Format",
"Custom File Format": "Custom File Format",
"General Data Exchange Format": "General Data Exchange Format",
"General Bank Statement Format": "General Bank Statement Format",
"Other Bank/Payment App Statement File": "Other Bank/Payment App Statement File",
"Other Finance App File Format": "Other Finance App File Format",
"ezbookkeeping Data Export File": "Archivo de exportación de datos de ezBookkeeping",
"Excel Workbook File": "Excel Workbook File",
"Open Financial Exchange (OFX) File": "Abrir archivo de intercambio financiero (OFX)",
+107 -94
View File
@@ -113,10 +113,11 @@ import {
} from '@/core/statistics.ts';
import {
type LocalizedImportFileCategoryAndTypes,
type LocalizedImportFileType,
type LocalizedImportFileTypeSubType,
type LocalizedImportFileTypeSupportedEncodings,
type LocalizedImportFileDocument,
type LocalizedImportFileDocument
} from '@/core/file.ts';
import type { LocaleDefaultSettings } from '@/core/setting.ts';
@@ -127,7 +128,7 @@ import { UTC_TIMEZONE, ALL_TIMEZONES } from '@/consts/timezone.ts';
import { ALL_CURRENCIES } from '@/consts/currency.ts';
import { DEFAULT_EXPENSE_CATEGORIES, DEFAULT_INCOME_CATEGORIES, DEFAULT_TRANSFER_CATEGORIES } from '@/consts/category.ts';
import { KnownErrorCode, SPECIFIED_API_NOT_FOUND_ERRORS, PARAMETERIZED_ERRORS } from '@/consts/api.ts';
import { DEFAULT_DOCUMENT_LANGUAGE_FOR_IMPORT_FILE, SUPPORTED_DOCUMENT_LANGUAGES_FOR_IMPORT_FILE, SUPPORTED_IMPORT_FILE_TYPES } from '@/consts/file.ts';
import { DEFAULT_DOCUMENT_LANGUAGE_FOR_IMPORT_FILE, SUPPORTED_DOCUMENT_LANGUAGES_FOR_IMPORT_FILE, SUPPORTED_IMPORT_FILE_CATEGORY_AND_TYPES } from '@/consts/file.ts';
import {
type CategorizedAccount,
@@ -1305,102 +1306,114 @@ export function useI18n() {
return availableExchangeRates;
}
function getAllSupportedImportFileTypes(): LocalizedImportFileType[] {
const allSupportedImportFileTypes: LocalizedImportFileType[] = [];
function getAllSupportedImportFileCagtegoryAndTypes(): LocalizedImportFileCategoryAndTypes[] {
const allSupportedImportFileCategoryAndTypes: LocalizedImportFileCategoryAndTypes[] = [];
for (let i = 0; i < SUPPORTED_IMPORT_FILE_TYPES.length; i++) {
const fileType = SUPPORTED_IMPORT_FILE_TYPES[i];
let document: LocalizedImportFileDocument | undefined;
for (let i = 0; i < SUPPORTED_IMPORT_FILE_CATEGORY_AND_TYPES.length; i++) {
const categoryAndTypes = SUPPORTED_IMPORT_FILE_CATEGORY_AND_TYPES[i];
if (fileType.document) {
let documentLanguage = '';
let documentDisplayLanguageName = '';
let documentAnchor = '';
if (fileType.document.supportMultiLanguages === true) {
documentLanguage = getCurrentLanguageTag();
if (SUPPORTED_DOCUMENT_LANGUAGES_FOR_IMPORT_FILE[documentLanguage] === documentLanguage) {
documentAnchor = t(`document.anchor.export_and_import.${fileType.document.anchor}`);
} else if (SUPPORTED_DOCUMENT_LANGUAGES_FOR_IMPORT_FILE[documentLanguage]) {
documentLanguage = SUPPORTED_DOCUMENT_LANGUAGES_FOR_IMPORT_FILE[documentLanguage];
documentAnchor = t(`document.anchor.export_and_import.${fileType.document.anchor}`, {}, { locale: documentLanguage });
} else {
documentLanguage = DEFAULT_DOCUMENT_LANGUAGE_FOR_IMPORT_FILE;
documentAnchor = t(`document.anchor.export_and_import.${fileType.document.anchor}`, {}, { locale: documentLanguage });
}
} else if (isString(fileType.document.supportMultiLanguages) && ALL_LANGUAGES[fileType.document.supportMultiLanguages]) {
documentLanguage = fileType.document.supportMultiLanguages;
documentAnchor = fileType.document.anchor;
}
if (documentLanguage && documentLanguage !== getCurrentLanguageTag()) {
documentDisplayLanguageName = getLanguageDisplayName(ALL_LANGUAGES[documentLanguage].name);
}
if (documentLanguage) {
documentLanguage = documentLanguage.replace(/-/g, '_');
}
if (documentAnchor) {
documentAnchor = documentAnchor.toLowerCase().replace(/ /g, '-');
}
if (documentLanguage === DEFAULT_LANGUAGE) {
documentLanguage = '';
}
document = {
language: documentLanguage,
displayLanguageName: documentDisplayLanguageName,
anchor: documentAnchor
};
} else {
document = undefined;
}
const subTypes: LocalizedImportFileTypeSubType[] = [];
if (fileType.subTypes) {
for (let i = 0; i < fileType.subTypes.length; i++) {
const subType = fileType.subTypes[i];
const localizedSubType: LocalizedImportFileTypeSubType = {
type: subType.type,
displayName: t(subType.name),
extensions: subType.extensions
};
subTypes.push(localizedSubType);
}
}
const supportedEncodings: LocalizedImportFileTypeSupportedEncodings[] = [];
if (fileType.supportedEncodings) {
for (let i = 0; i < fileType.supportedEncodings.length; i++) {
const encoding = fileType.supportedEncodings[i];
const localizedEncoding: LocalizedImportFileTypeSupportedEncodings = {
encoding: encoding,
displayName: t(`encoding.${encoding}`)
};
supportedEncodings.push(localizedEncoding);
}
}
const localizedFileType: LocalizedImportFileType = {
type: fileType.type,
displayName: t(fileType.name),
extensions: fileType.extensions,
subTypes: subTypes.length ? subTypes : undefined,
supportedEncodings: supportedEncodings.length ? supportedEncodings : undefined,
dataFromTextbox: fileType.dataFromTextbox,
document: document
const localizedCategoryAndTypes: LocalizedImportFileCategoryAndTypes = {
displayCategoryName: t(categoryAndTypes.categoryName),
fileTypes: []
};
allSupportedImportFileTypes.push(localizedFileType);
for (let j = 0; j < categoryAndTypes.fileTypes.length; j++) {
const fileType = categoryAndTypes.fileTypes[j];
let document: LocalizedImportFileDocument | undefined;
if (fileType.document) {
let documentLanguage = '';
let documentDisplayLanguageName = '';
let documentAnchor = '';
if (fileType.document.supportMultiLanguages === true) {
documentLanguage = getCurrentLanguageTag();
if (SUPPORTED_DOCUMENT_LANGUAGES_FOR_IMPORT_FILE[documentLanguage] === documentLanguage) {
documentAnchor = t(`document.anchor.export_and_import.${fileType.document.anchor}`);
} else if (SUPPORTED_DOCUMENT_LANGUAGES_FOR_IMPORT_FILE[documentLanguage]) {
documentLanguage = SUPPORTED_DOCUMENT_LANGUAGES_FOR_IMPORT_FILE[documentLanguage];
documentAnchor = t(`document.anchor.export_and_import.${fileType.document.anchor}`, {}, { locale: documentLanguage });
} else {
documentLanguage = DEFAULT_DOCUMENT_LANGUAGE_FOR_IMPORT_FILE;
documentAnchor = t(`document.anchor.export_and_import.${fileType.document.anchor}`, {}, { locale: documentLanguage });
}
} else if (isString(fileType.document.supportMultiLanguages) && ALL_LANGUAGES[fileType.document.supportMultiLanguages]) {
documentLanguage = fileType.document.supportMultiLanguages;
documentAnchor = fileType.document.anchor;
}
if (documentLanguage && documentLanguage !== getCurrentLanguageTag()) {
documentDisplayLanguageName = getLanguageDisplayName(ALL_LANGUAGES[documentLanguage].name);
}
if (documentLanguage) {
documentLanguage = documentLanguage.replace(/-/g, '_');
}
if (documentAnchor) {
documentAnchor = documentAnchor.toLowerCase().replace(/ /g, '-');
}
if (documentLanguage === DEFAULT_LANGUAGE) {
documentLanguage = '';
}
document = {
language: documentLanguage,
displayLanguageName: documentDisplayLanguageName,
anchor: documentAnchor
};
} else {
document = undefined;
}
const subTypes: LocalizedImportFileTypeSubType[] = [];
if (fileType.subTypes) {
for (let k = 0; k < fileType.subTypes.length; k++) {
const subType = fileType.subTypes[k];
const localizedSubType: LocalizedImportFileTypeSubType = {
type: subType.type,
displayName: t(subType.name),
extensions: subType.extensions
};
subTypes.push(localizedSubType);
}
}
const supportedEncodings: LocalizedImportFileTypeSupportedEncodings[] = [];
if (fileType.supportedEncodings) {
for (let k = 0; k < fileType.supportedEncodings.length; k++) {
const encoding = fileType.supportedEncodings[k];
const localizedEncoding: LocalizedImportFileTypeSupportedEncodings = {
encoding: encoding,
displayName: t(`encoding.${encoding}`)
};
supportedEncodings.push(localizedEncoding);
}
}
const localizedFileType: LocalizedImportFileType = {
type: fileType.type,
displayName: t(fileType.name),
extensions: fileType.extensions,
subTypes: subTypes.length ? subTypes : undefined,
supportedEncodings: supportedEncodings.length ? supportedEncodings : undefined,
dataFromTextbox: fileType.dataFromTextbox,
document: document
};
localizedCategoryAndTypes.fileTypes.push(localizedFileType);
}
allSupportedImportFileCategoryAndTypes.push(localizedCategoryAndTypes);
}
return allSupportedImportFileTypes;
return allSupportedImportFileCategoryAndTypes;
}
function getLanguageInfo(languageKey: string): LanguageInfo | undefined {
@@ -2110,7 +2123,7 @@ export function useI18n() {
getAllImportTransactionColumnTypes: () => getLocalizedDisplayNameAndType(ImportTransactionColumnType.values()),
getAllTransactionDefaultCategories,
getAllDisplayExchangeRates,
getAllSupportedImportFileTypes,
getAllSupportedImportFileCagtegoryAndTypes,
// get localized info
getLanguageInfo,
getMonthShortName,
+8
View File
@@ -1727,9 +1727,17 @@
"Check and Modify Your Data": "Controlla e modifica i tuoi dati",
"Data Import Completed": "Importazione dati completata",
"File Type": "Tipo di file",
"Find file type": "Find file type",
"No available file type": "No available file type",
"Filter Description": "Filtra descrizione",
"How to import this file?": "How to import this file?",
"How to export this file?": "Come esportare questo file?",
"ezBookkeeping File Format": "ezBookkeeping File Format",
"Custom File Format": "Custom File Format",
"General Data Exchange Format": "General Data Exchange Format",
"General Bank Statement Format": "General Bank Statement Format",
"Other Bank/Payment App Statement File": "Other Bank/Payment App Statement File",
"Other Finance App File Format": "Other Finance App File Format",
"ezbookkeeping Data Export File": "File esportazione dati ezBookkeeping",
"Excel Workbook File": "Excel Workbook File",
"Open Financial Exchange (OFX) File": "File Open Financial Exchange (OFX)",
+8
View File
@@ -1727,9 +1727,17 @@
"Check and Modify Your Data": "データの確認と修正をします",
"Data Import Completed": "データのインポートが完了しました",
"File Type": "ファイルの種類",
"Find file type": "Find file type",
"No available file type": "No available file type",
"Filter Description": "フィルターの説明",
"How to import this file?": "How to import this file?",
"How to export this file?": "このファイルをエクスポートする方法",
"ezBookkeeping File Format": "ezBookkeeping File Format",
"Custom File Format": "Custom File Format",
"General Data Exchange Format": "General Data Exchange Format",
"General Bank Statement Format": "General Bank Statement Format",
"Other Bank/Payment App Statement File": "Other Bank/Payment App Statement File",
"Other Finance App File Format": "Other Finance App File Format",
"ezbookkeeping Data Export File": "ezbookkeepingデータエクスポートファイル",
"Excel Workbook File": "Excel Workbook File",
"Open Financial Exchange (OFX) File": "Open Financial Exchange (OFX) ファイル",
+8
View File
@@ -1727,9 +1727,17 @@
"Check and Modify Your Data": "Controleer en pas je gegevens aan",
"Data Import Completed": "Gegevensimport voltooid",
"File Type": "Bestandstype",
"Find file type": "Find file type",
"No available file type": "No available file type",
"Filter Description": "Filterbeschrijving",
"How to import this file?": "Hoe importeer ik dit bestand?",
"How to export this file?": "Hoe exporteer ik dit bestand?",
"ezBookkeeping File Format": "ezBookkeeping File Format",
"Custom File Format": "Custom File Format",
"General Data Exchange Format": "General Data Exchange Format",
"General Bank Statement Format": "General Bank Statement Format",
"Other Bank/Payment App Statement File": "Other Bank/Payment App Statement File",
"Other Finance App File Format": "Other Finance App File Format",
"ezbookkeeping Data Export File": "ezBookkeeping-gegevensexportbestand",
"Excel Workbook File": "Excel-werkmap",
"Open Financial Exchange (OFX) File": "Open Financial Exchange (OFX)-bestand",
+8
View File
@@ -1727,9 +1727,17 @@
"Check and Modify Your Data": "Verificar e Modificar Seus Dados",
"Data Import Completed": "Importação de Dados Concluída",
"File Type": "Tipo de Arquivo",
"Find file type": "Find file type",
"No available file type": "No available file type",
"Filter Description": "Descrição do Filtro",
"How to import this file?": "Como importar este arquivo?",
"How to export this file?": "Como exportar este arquivo?",
"ezBookkeeping File Format": "ezBookkeeping File Format",
"Custom File Format": "Custom File Format",
"General Data Exchange Format": "General Data Exchange Format",
"General Bank Statement Format": "General Bank Statement Format",
"Other Bank/Payment App Statement File": "Other Bank/Payment App Statement File",
"Other Finance App File Format": "Other Finance App File Format",
"ezbookkeeping Data Export File": "Arquivo de Exportação de Dados ezbookkeeping",
"Excel Workbook File": "Excel Workbook File",
"Open Financial Exchange (OFX) File": "Arquivo Open Financial Exchange (OFX)",
+8
View File
@@ -1727,9 +1727,17 @@
"Check and Modify Your Data": "Проверьте и измените свои данные",
"Data Import Completed": "Импорт данных завершен",
"File Type": "Тип файла",
"Find file type": "Find file type",
"No available file type": "No available file type",
"Filter Description": "Описание фильтра",
"How to import this file?": "How to import this file?",
"How to export this file?": "Как экспортировать этот файл?",
"ezBookkeeping File Format": "ezBookkeeping File Format",
"Custom File Format": "Custom File Format",
"General Data Exchange Format": "General Data Exchange Format",
"General Bank Statement Format": "General Bank Statement Format",
"Other Bank/Payment App Statement File": "Other Bank/Payment App Statement File",
"Other Finance App File Format": "Other Finance App File Format",
"ezbookkeeping Data Export File": "Файл экспорта данных ezbookkeeping",
"Excel Workbook File": "Excel Workbook File",
"Open Financial Exchange (OFX) File": "Файл Open Financial Exchange (OFX)",
+8
View File
@@ -1727,9 +1727,17 @@
"Check and Modify Your Data": "Перевірте та змініть свої дані",
"Data Import Completed": "Імпорт даних завершено",
"File Type": "Тип файлу",
"Find file type": "Find file type",
"No available file type": "No available file type",
"Filter Description": "Опис фільтра",
"How to import this file?": "How to import this file?",
"How to export this file?": "Як експортувати цей файл?",
"ezBookkeeping File Format": "ezBookkeeping File Format",
"Custom File Format": "Custom File Format",
"General Data Exchange Format": "General Data Exchange Format",
"General Bank Statement Format": "General Bank Statement Format",
"Other Bank/Payment App Statement File": "Other Bank/Payment App Statement File",
"Other Finance App File Format": "Other Finance App File Format",
"ezbookkeeping Data Export File": "Файл експорту даних ezbookkeeping",
"Excel Workbook File": "Excel Workbook File",
"Open Financial Exchange (OFX) File": "Файл Open Financial Exchange (OFX)",
+8
View File
@@ -1727,9 +1727,17 @@
"Check and Modify Your Data": "Kiểm tra và sửa đổi dữ liệu của bạn",
"Data Import Completed": "Nhập dữ liệu hoàn tất",
"File Type": "Loại tệp",
"Find file type": "Find file type",
"No available file type": "No available file type",
"Filter Description": "Mô tả bộ lọc",
"How to import this file?": "How to import this file?",
"How to export this file?": "Làm thế nào để xuất tệp này?",
"ezBookkeeping File Format": "ezBookkeeping File Format",
"Custom File Format": "Custom File Format",
"General Data Exchange Format": "General Data Exchange Format",
"General Bank Statement Format": "General Bank Statement Format",
"Other Bank/Payment App Statement File": "Other Bank/Payment App Statement File",
"Other Finance App File Format": "Other Finance App File Format",
"ezbookkeeping Data Export File": "Tệp xuất dữ liệu ezbookkeeping",
"Excel Workbook File": "Excel Workbook File",
"Open Financial Exchange (OFX) File": "Tệp Open Financial Exchange (OFX)",
+8
View File
@@ -1727,9 +1727,17 @@
"Check and Modify Your Data": "检查及修改您的数据",
"Data Import Completed": "数据导入完成",
"File Type": "文件类型",
"Find file type": "查找文件类型",
"No available file type": "没有可用的文件类型",
"Filter Description": "过滤描述",
"How to import this file?": "如何导入该文件?",
"How to export this file?": "如何导出该文件?",
"ezBookkeeping File Format": "ezBookkeeping 文件格式",
"Custom File Format": "自定义文件格式",
"General Data Exchange Format": "通用数据交换格式",
"General Bank Statement Format": "通用银行对账单格式",
"Other Bank/Payment App Statement File": "其他银行/支付应用对账单文件",
"Other Finance App File Format": "其他金融应用文件格式",
"ezbookkeeping Data Export File": "ezbookkeeping 数据导出文件",
"Excel Workbook File": "Excel 工作簿文件",
"Open Financial Exchange (OFX) File": "开放式金融交换 (OFX) 文件",
+8
View File
@@ -1727,9 +1727,17 @@
"Check and Modify Your Data": "檢查及修改您的資料",
"Data Import Completed": "資料匯入完成",
"File Type": "檔案類型",
"Find file type": "搜尋檔案類型",
"No available file type": "沒有可用的檔案類型",
"Filter Description": "篩選描述",
"How to import this file?": "如何匯入此檔案?",
"How to export this file?": "如何匯出此檔案?",
"ezBookkeeping File Format": "ezBookkeeping 檔案格式",
"Custom File Format": "自訂檔案格式",
"General Data Exchange Format": "通用資料交換格式",
"General Bank Statement Format": "通用銀行對帳單格式",
"Other Bank/Payment App Statement File": "其他銀行/支付應用程式對帳單檔案",
"Other Finance App File Format": "其他金融應用程式檔案格式",
"ezbookkeeping Data Export File": "ezbookkeeping 資料匯出檔案",
"Excel Workbook File": "Excel 工作簿檔案",
"Open Financial Exchange (OFX) File": "開放式金融交換 (OFX) 檔案",