fix(translate): French error messages and update mock users for quota checks
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 2m52s
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 2m52s
This commit is contained in:
@@ -100,15 +100,15 @@ class TranslateEndpointError(Exception):
|
||||
PRO_FEATURE_REQUIRED = "PRO_FEATURE_REQUIRED"
|
||||
|
||||
ERROR_MESSAGES = {
|
||||
INVALID_FORMAT: "Unsupported file format. Accepted formats: .xlsx, .docx, .pptx",
|
||||
CORRUPTED_FILE: "The file appears corrupted or is not a valid Office document.",
|
||||
FILE_TOO_LARGE: f"File is too large (max {MAX_FILE_SIZE_MB} MB).",
|
||||
QUOTA_EXCEEDED: "Monthly translation limit reached.",
|
||||
URL_DOWNLOAD_FAILED: "Failed to download file from URL.",
|
||||
URL_UNREACHABLE: "URL unreachable.",
|
||||
UNAUTHORIZED: "Authentication required.",
|
||||
MISSING_FILE: "File or URL required.",
|
||||
PRO_FEATURE_REQUIRED: "This feature requires a Pro subscription.",
|
||||
INVALID_FORMAT: "Format de fichier non pris en charge. Formats acceptés : .xlsx, .docx, .pptx",
|
||||
CORRUPTED_FILE: "Le fichier semble corrompu ou n'est pas un document Office valide.",
|
||||
FILE_TOO_LARGE: f"Le fichier est trop volumineux (max {MAX_FILE_SIZE_MB} Mo).",
|
||||
QUOTA_EXCEEDED: "Limite mensuelle de traduction atteinte.",
|
||||
URL_DOWNLOAD_FAILED: "Échec du téléchargement du fichier depuis l'URL.",
|
||||
URL_UNREACHABLE: "URL inaccessible.",
|
||||
UNAUTHORIZED: "Authentification requise.",
|
||||
MISSING_FILE: "Fichier ou URL requis.",
|
||||
PRO_FEATURE_REQUIRED: "Cette fonctionnalité nécessite un abonnement Pro.",
|
||||
}
|
||||
|
||||
def __init__(
|
||||
@@ -169,8 +169,8 @@ async def validate_file_content(content: bytes, extension: str) -> None:
|
||||
if len(content) < 4:
|
||||
raise TranslateEndpointError(
|
||||
code=TranslateEndpointError.CORRUPTED_FILE,
|
||||
message="File is too small to be a valid document.",
|
||||
details={"reason": "File is too small"},
|
||||
message="Le fichier est trop petit pour être un document valide.",
|
||||
details={"reason": "Fichier trop petit"},
|
||||
)
|
||||
|
||||
header = content[:5]
|
||||
@@ -179,8 +179,8 @@ async def validate_file_content(content: bytes, extension: str) -> None:
|
||||
if not header[:4] == PDF_MAGIC_BYTES:
|
||||
raise TranslateEndpointError(
|
||||
code=TranslateEndpointError.CORRUPTED_FILE,
|
||||
message="File is not a valid PDF.",
|
||||
details={"reason": "Invalid PDF header"},
|
||||
message="Le fichier n'est pas un PDF valide.",
|
||||
details={"reason": "En-tête PDF invalide"},
|
||||
)
|
||||
return
|
||||
|
||||
@@ -188,10 +188,10 @@ async def validate_file_content(content: bytes, extension: str) -> None:
|
||||
if header[:4] != OFFICE_MAGIC_BYTES:
|
||||
raise TranslateEndpointError(
|
||||
code=TranslateEndpointError.CORRUPTED_FILE,
|
||||
message="File is not a valid Office document.",
|
||||
message="Le fichier n'est pas un document Office valide ou est corrompu.",
|
||||
details={
|
||||
"accepted_formats": list(ACCEPTED_EXTENSIONS),
|
||||
"hint": "Office files (.xlsx, .docx, .pptx) must be valid ZIP archives.",
|
||||
"hint": "Les fichiers Office (.xlsx, .docx, .pptx) doivent être des archives ZIP valides.",
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user