- Add 'language' column to waitlist_entries (en/it/es/fr/de, default en) - Accept 'lang' field in POST /waitlist request body - Translate confirmation email (subject, badge, heading, body, CTA, footer) - Translate confirm/unsubscribe result HTML pages - Return localized success message in WaitlistResponse - Update language preference on duplicate signups - Alembic migration 003_add_language_column
31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
from typing import Literal
|
|
|
|
from pydantic import BaseModel, EmailStr, Field
|
|
|
|
SUPPORTED_LANGS = ("en", "it", "es", "fr", "de")
|
|
|
|
|
|
class WaitlistRequest(BaseModel):
|
|
email: EmailStr
|
|
lang: Literal["en", "it", "es", "fr", "de"] = "en"
|
|
# Honeypot field — must be empty. Bots tend to fill hidden fields.
|
|
website: str = Field(default="", max_length=0)
|
|
|
|
|
|
_RESPONSE_MESSAGES: dict[str, str] = {
|
|
"en": "Check your inbox for a confirmation link!",
|
|
"it": "Controlla la tua casella email per il link di conferma!",
|
|
"es": "¡Revisa tu bandeja de entrada para el enlace de confirmación!",
|
|
"fr": "Vérifiez votre boîte de réception pour le lien de confirmation !",
|
|
"de": "Überprüfe deinen Posteingang für den Bestätigungslink!",
|
|
}
|
|
|
|
|
|
class WaitlistResponse(BaseModel):
|
|
ok: bool = True
|
|
message: str = "Check your inbox for a confirmation link!"
|
|
|
|
@classmethod
|
|
def for_lang(cls, lang: str = "en") -> "WaitlistResponse":
|
|
return cls(message=_RESPONSE_MESSAGES.get(lang, _RESPONSE_MESSAGES["en"]))
|