|
| 1 | +/// Extension de localisation des [NotesErrorCode] vers des messages |
| 2 | +/// utilisateur dans la langue active (FR/EN). |
| 3 | +/// |
| 4 | +/// Pattern d'usage côté UI : |
| 5 | +/// |
| 6 | +/// ```dart |
| 7 | +/// } on NotesTechException catch (e) { |
| 8 | +/// final code = e.code; |
| 9 | +/// _showError(code != null ? code.localize(t) : t.commonErrorWith('$e')); |
| 10 | +/// } |
| 11 | +/// ``` |
| 12 | +library; |
| 13 | + |
| 14 | +import '../core/exceptions.dart'; |
| 15 | +import '../l10n/app_localizations.dart'; |
| 16 | + |
| 17 | +extension NotesErrorLocalize on NotesErrorCode { |
| 18 | + /// Renvoie le message utilisateur localisé pour ce code, dans la |
| 19 | + /// langue active de l'app. |
| 20 | + String localize(AppLocalizations t) { |
| 21 | + switch (this) { |
| 22 | + case NotesErrorCode.folderNameRequired: |
| 23 | + return t.errorFolderNameRequired; |
| 24 | + case NotesErrorCode.inboxNotDeletable: |
| 25 | + return t.errorInboxNotDeletable; |
| 26 | + case NotesErrorCode.noteTitleTooLong: |
| 27 | + return t.errorNoteTitleTooLong; |
| 28 | + case NotesErrorCode.vaultAlreadyEnabled: |
| 29 | + return t.errorVaultAlreadyEnabled; |
| 30 | + case NotesErrorCode.vaultPassphraseTooShort: |
| 31 | + return t.errorVaultPassphraseTooShort; |
| 32 | + case NotesErrorCode.vaultPassphraseWrong: |
| 33 | + return t.errorVaultPassphraseWrong; |
| 34 | + case NotesErrorCode.vaultPinTooShort: |
| 35 | + return t.errorVaultPinTooShort; |
| 36 | + case NotesErrorCode.vaultPinNotDigits: |
| 37 | + return t.errorVaultPinNotDigits; |
| 38 | + case NotesErrorCode.vaultPinWrong: |
| 39 | + return t.errorVaultPinWrong; |
| 40 | + case NotesErrorCode.vaultPinWiped: |
| 41 | + return t.errorVaultPinWiped; |
| 42 | + case NotesErrorCode.vaultNotPinVault: |
| 43 | + return t.errorVaultNotPinVault; |
| 44 | + case NotesErrorCode.vaultNotAVault: |
| 45 | + return t.errorVaultNotAVault; |
| 46 | + case NotesErrorCode.vaultLocked: |
| 47 | + return t.errorVaultLocked; |
| 48 | + case NotesErrorCode.vaultEncryptedContentInvalid: |
| 49 | + return t.errorVaultEncryptedContentInvalid; |
| 50 | + case NotesErrorCode.vaultWrapInvalid: |
| 51 | + return t.errorVaultWrapInvalid; |
| 52 | + case NotesErrorCode.gemmaModelNotInstalled: |
| 53 | + return t.errorGemmaModelNotInstalled; |
| 54 | + case NotesErrorCode.gemmaFileNotFound: |
| 55 | + return t.errorGemmaFileNotFound; |
| 56 | + case NotesErrorCode.gemmaFileTooSmall: |
| 57 | + return t.errorGemmaFileTooSmall; |
| 58 | + case NotesErrorCode.gemmaFileTooLarge: |
| 59 | + return t.errorGemmaFileTooLarge; |
| 60 | + case NotesErrorCode.gemmaInitFailed: |
| 61 | + return t.errorGemmaInitFailed; |
| 62 | + case NotesErrorCode.gemmaNotLoaded: |
| 63 | + return t.errorGemmaNotLoaded; |
| 64 | + case NotesErrorCode.gemmaBusy: |
| 65 | + return t.errorGemmaBusy; |
| 66 | + case NotesErrorCode.gemmaHashMismatch: |
| 67 | + return t.errorGemmaHashMismatch; |
| 68 | + } |
| 69 | + } |
| 70 | +} |
0 commit comments