plateCheck.ts 536 B

123456789101112131415
  1. import type { TFunction } from 'i18next';
  2. const PLATE_CHECK_FAILURE_REASONS = [
  3. 'no_camera_frame',
  4. 'decode_failed',
  5. 'analysis_error',
  6. 'opencv_missing',
  7. 'not_calibrated',
  8. ] as const;
  9. /** Why a plate check could not run, in the reader's language. */
  10. export function plateCheckFailureText(t: TFunction, reason: string | null | undefined): string {
  11. const known = (PLATE_CHECK_FAILURE_REASONS as readonly string[]).includes(reason ?? '');
  12. return t(`printers.plateDetection.unavailableReasons.${known ? reason : 'error'}`);
  13. }