-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auth translation in _scaffold #718
Comments
In _scaffold/auth/register Buttons are translated ok: but not the field Labels ???? |
I've solved this by using the form style translation snippet I mentioned here: #719 (comment) along an Auth subclass. It changes the MESSAGES variable to a generic translatable string, and I've extracted the English texts to a translation file. Then I set the form style of this Auth subclass to the TranslatedFormStyleFactory(T) which I've collapsed the code, since its quite long: Code and en.json translation fileclass TranslatedAuth(Auth):
MESSAGES = { # noqa: RUF012
"verify_email": {
"subject": "auth.verify_email.subject",
"body": "auth.verify_email.body",
},
"reset_password": {
"subject": "auth.reset_password.subject",
"body": "auth.reset_password.body",
},
"unsubscribe": {
"subject": "auth.unsubscribe.subject",
"body": "auth.unsubscribe.body",
},
"flash": {
"user-registered": "auth.unsubscribe.user-registered",
"password-reset-link-sent": "auth.unsubscribe.password-reset-link-sent",
"password-changed": "auth.unsubscribe.password-changed",
"profile-saved": "auth.unsubscribe.profile-saved",
"user-logout": "auth.unsubscribe.user-logout",
"email-verified": "auth.unsubscribe.email-verified",
"link-expired": "auth.unsubscribe.link-expired",
},
"labels": {
"username": "auth.labels.username",
"email": "auth.labels.email",
"first_name": "auth.labels.first_name",
"last_name": "auth.labels.last_name",
"phone_number": "auth.labels.phone_number",
"username_or_email": "auth.labels.username_or_email",
"password": "auth.labels.password",
"new_password": "auth.labels.new_password",
"old_password": "auth.labels.old_password",
"login_password": "auth.labels.login_password",
"password_again": "auth.labels.password_again",
"created_on": "auth.labels.created_on",
"created_by": "auth.labels.created_by",
"modified on": "auth.labels.modified on",
"modified by": "auth.labels.modified by",
"two_factor": "auth.labels.two_factor",
},
"buttons": {
"lost-password": "auth.buttons.lost-password",
"register": "auth.buttons.register",
"request": "auth.buttons.request",
"sign-in": "auth.buttons.sign-in",
"sign-up": "auth.buttons.sign-up",
"submit": "auth.buttons.submit",
},
"errors": {
"registration_is_pending": "auth.errors.registration_is_pending",
"account_is_blocked": "auth.errors.account_is_blocked",
"account_needs_to_be_approved": "auth.errors.account_needs_to_be_approved",
"invalid_credentials": "auth.errors.invalid_credentials",
"invalid_token": "auth.errors.invalid_token",
"password_doesnt_match": "auth.errors.password_doesnt_match",
"invalid_current_password": "auth.errors.invalid_current_password",
"new_password_is_the_same_as_previous_password": (
"auth.errors.new_password_is_the_same_as_previous_password"
),
"new_password_was_already_used": (
"auth.errors.new_password_was_already_used"
),
"invalid": "auth.errors.invalid",
"no_post_payload": "auth.errors.no_post_payload",
"two_factor": "auth.errors.two_factor",
"two_factor_max_tries": "auth.errors.two_factor_max_tries",
},
} {
"auth.verify_email.subject": {
"0": "Confirm email"
},
"auth.verify_email.body": {
"0": "Welcome {first_name}, click {link} to confirm your email"
},
"auth.reset_password.subject": {
"0": "Password reset"
},
"auth.reset_password.body": {
"0": "Hello {first_name}, click {link} to change password"
},
"auth.unsubscribe.subject": {
"0": "Unsubscribe confirmation"
},
"auth.unsubscribe.body": {
"0": "By {first_name}, you have been erased from our system"
},
"auth.flash.user-registered": {
"0": "User registered"
},
"auth.flash.password-reset-link-sent": {
"0": "Password reset link sent"
},
"auth.flash.password-changed": {
"0": "Password changed"
},
"auth.flash.profile-saved": {
"0": "Profile saved"
},
"auth.flash.user-logout": {
"0": "User logout"
},
"auth.flash.email-verified": {
"0": "Email verified"
},
"auth.flash.link-expired": {
"0": "Link invalid or expired"
},
"auth.labels.username": {
"0": "Username"
},
"auth.labels.email": {
"0": "Email"
},
"auth.labels.first_name": {
"0": "First Name"
},
"auth.labels.last_name": {
"0": "Last Name"
},
"auth.labels.phone_number": {
"0": "Phone Number"
},
"auth.labels.username_or_email": {
"0": "Username or Email"
},
"auth.labels.password": {
"0": "Password"
},
"auth.labels.new_password": {
"0": "New Password"
},
"auth.labels.old_password": {
"0": "Old Password"
},
"auth.labels.login_password": {
"0": "Password"
},
"auth.labels.password_again": {
"0": "Password (again)"
},
"auth.labels.created_on": {
"0": "Created On"
},
"auth.labels.created_by": {
"0": "Created By"
},
"auth.labels.modified on": {
"0": "Modified On"
},
"auth.labels.modified by": {
"0": "Modified By"
},
"auth.labels.two_factor": {
"0": "Authentication Code"
},
"auth.buttons.lost-password": {
"0": "Lost Password"
},
"auth.buttons.register": {
"0": "Register"
},
"auth.buttons.request": {
"0": "Request"
},
"auth.buttons.sign-in": {
"0": "Sign In"
},
"auth.buttons.sign-up": {
"0": "Sign Up"
},
"auth.buttons.sign-out": {
"0": "Sign Out"
},
"auth.buttons.submit": {
"0": "Submit"
},
"auth.errors.registration_is_pending": {
"0": "Registration is pending"
},
"auth.errors.account_is_blocked": {
"0": "Account is blocked"
},
"auth.errors.account_needs_to_be_approved": {
"0": "Account needs to be approved"
},
"auth.errors.invalid_credentials": {
"0": "Invalid Credentials"
},
"auth.errors.invalid_token": {
"0": "invalid token"
},
"auth.errors.password_doesnt_match": {
"0": "Password doesn't match"
},
"auth.errors.invalid_current_password": {
"0": "invalid current password"
},
"auth.errors.new_password_is_the_same_as_previous_password": {
"0": "new password is the same as previous password"
},
"auth.errors.new_password_was_already_used": {
"0": "new password was already used"
},
"auth.errors.invalid": {
"0": "invalid"
},
"auth.errors.no_post_payload": {
"0": "no post payload"
},
"auth.errors.two_factor": {
"0": "Verification code does not match"
},
"auth.errors.two_factor_max_tries": {
"0": "Two factor max tries exceeded"
}
} |
Need to translate native Auth labels/messages in the _scaffold app (spanish, ...) at least to a minimal start point.
Once that is working, the community could complete the diferent translations.
The text was updated successfully, but these errors were encountered: