[Backend] Let reCAPTCHA error messages use translation
Related to #488 (closed).
This is a upstream tracker issue for overwriting reCAPTCHA error message.
- Upstream Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/354071
- Upstream MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/81977
Summary
The reCAPTCHA service can not fulfill the requirements of Jihu GitLab, we are doing some tweaks to let it work harmonically with Tencent Cloud Captcha.
The error message should not include the keyword "reCAPTCHA" once the tweaking is done. The problem is that there are several places of reCAPTCHA error messages are hardcoded as string which could be replaced with the translation method.
Improvements
Code Level
Before
expect(flash[:alert]).to include 'There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.'
After
expect(flash[:alert]).to include _('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.')
UI Level
No changes on GitLab UI, but it can let Jihu have the ability to customize the captcha error message as the following image shows.
Risks
No breaks
Involved components
- app/models/concerns/spammable.rb
- spec/controllers/confirmations_controller_spec.rb
- spec/controllers/passwords_controller_spec.rb
- spec/controllers/sessions_controller_spec.rb
- spec/features/users/signup_spec.rb
- spec/models/concerns/spammable_spec.rb
- locale/gitlab.pot