Files
cutdex/lib/l10n/app_messages.dart
T
lingjhf 2e0033ce2d
Gitea CI / Build Android APK (pull_request) Canceled after 0s
Gitea CI / Build Windows x64 app (pull_request) Canceled after 0s
Gitea CI / Audit and package Windows x64 (pull_request) Canceled after 0s
Gitea CI / Assemble and validate CI artifacts (pull_request) Canceled after 0s
Gitea CI / Gitea CI passed (pull_request) Canceled after 0s
Gitea CI / Check code and tests (pull_request) Canceled after 6m29s
feat(workspace): refresh desktop editing experience and prepare 0.1.2
2026-10-09 01:56:01 +08:00

71 lines
3.7 KiB
Dart

import '../errors/app_failure.dart';
import '../integrations/app_failure_adapter.dart';
import 'app_localizations.dart';
/// Presentation is the only layer that translates application failures.
extension LocalizedAppMessages on AppLocalizations {
String errorMessage(Object error) =>
failureMessage(appFailureFromError(error));
String failureMessage(AppFailure failure) => switch (failure.code) {
AppErrorCode.operationFailed => operationFailed,
AppErrorCode.agentRestartHint => agentRestartHint,
AppErrorCode.loadRecentProjectsFailed => loadRecentProjectsFailed,
AppErrorCode.loadProjectsFailed => loadProjectsFailed,
AppErrorCode.projectAccessFailed => projectAccessFailed,
AppErrorCode.projectLocationNotWritable => projectLocationNotWritable,
AppErrorCode.projectLocationUnavailable => projectLocationUnavailable,
AppErrorCode.projectLocationCreateFailed => projectLocationCreateFailed,
AppErrorCode.projectMissingDirectory => projectMissingDirectory,
AppErrorCode.recentProjectSaveFailed => recentProjectSaveFailed,
AppErrorCode.lastProjectSaveFailed => lastProjectSaveFailed,
AppErrorCode.enterProjectName => enterProjectName,
AppErrorCode.projectSwitched => projectSwitched,
AppErrorCode.notLocalMedia => notLocalMedia,
AppErrorCode.revealMediaFailed => revealMediaFailed,
AppErrorCode.openMatchingProject => openMatchingProject,
AppErrorCode.openTimelineFailed => openTimelineFailed,
AppErrorCode.projectMismatch => projectMismatch,
AppErrorCode.projectAlreadyExists => projectAlreadyExists,
AppErrorCode.openProjectFirst => openProjectFirst,
AppErrorCode.localFilesOnly => localFilesOnly,
AppErrorCode.foldersUnsupported => foldersUnsupported,
AppErrorCode.mediaImportCancelled => mediaImportCancelled,
AppErrorCode.fileAccessFailed => fileAccessFailed,
AppErrorCode.registerMediaFailed => registerMediaFailed,
AppErrorCode.mediaNoLongerExists => mediaNoLongerExists,
AppErrorCode.mediaNoTracks => mediaNoTracks,
AppErrorCode.invalidMediaDuration => invalidMediaDuration,
AppErrorCode.mediaInfoUnsupported => mediaInfoUnsupported,
AppErrorCode.mediaInfoFailed => mediaInfoFailed,
AppErrorCode.saveTimelineFailed => saveTimelineFailed,
AppErrorCode.projectNameInvalid => projectNameInvalid,
AppErrorCode.projectLocationDefaultUnavailable =>
projectLocationDefaultUnavailable,
AppErrorCode.chooseProjectLocation => chooseProjectLocation,
AppErrorCode.timelineMissing => timelineMissing,
AppErrorCode.timelineInUse => timelineInUse,
AppErrorCode.timelineHasBackgroundTasks => timelineHasBackgroundTasks,
AppErrorCode.timelineRequired => timelineRequired,
AppErrorCode.projectSessionClosed => projectSessionClosed,
AppErrorCode.timelineSessionClosed => timelineSessionClosed,
AppErrorCode.mediaReadFailed => mediaReadFailed,
AppErrorCode.mediaImportFailed => mediaImportFailed,
AppErrorCode.unsupportedMediaType => unsupportedMediaType,
AppErrorCode.mediaNoVideoTracks => mediaNoVideoTracks,
AppErrorCode.mediaDurationOutOfRange => mediaDurationOutOfRange,
AppErrorCode.resourceChecksumFailed => resourceChecksumFailed,
AppErrorCode.enterName => enterName,
AppErrorCode.agentLocationUnavailable => agentLocationUnavailable,
AppErrorCode.agentLocationBusy => agentLocationBusy,
AppErrorCode.startBackgroundRemovalFailed => startBackgroundRemovalFailed,
AppErrorCode.subtitleEngineUnavailable => subtitleEngineUnavailable,
AppErrorCode.timelineChanged => timelineChanged,
AppErrorCode.resourceDownloadHttpFailed => resourceDownloadHttpFailed(
failure.httpStatusCode?.toString() ?? '—',
),
AppErrorCode.diagnostic => failure.diagnostic ?? operationFailed,
};
}