Resolve "Devise i18n support"
What does this MR do and why?
This MR is related to issue #1347 (closed):Devise i18n support
There are two things to accomplish in this MR:
-
Add
zh_CN.yml
inconfig/locales
directory for I18n.The
zh_CN.yml
is for zh_CN translation as I18n.The file can be placed in any directory (including JH) and loaded into the program via
I18n.load_path
.Not only 'JH' needs to implement zh_CN translation, but also the subsequent upstream. So we should put the file in upstream. (According to the official I18n convention, the file should be placed in the
config/locales
directory)Add a test case for this change.
-
Ensure I18n messages can be translated correctly.
Because upstream does not have a multi-language switching code at present, only English is used. Only JH I18n message translation problem is solved here.
There are two I18n keys used but not translated correctly in JH:
-
devise.failure.invalid
: Login failed error messageThis key cannot be translated correctly because it belongs to the
devise
error message, generated byFailureApp#respond
under the devise gem. AndFailureApp Controller
inherits fromActionController::Metal
instead ofApplicationController
, so therespond
action is not covered byset_locale
.Thedesign.failure.invalid
key is translated bydefault_locale
(:en).Solution in this MR :
FailureApp#respond
gets the message through thei18n_message
method, which is overridden by JH. So makeset_locale
covering that override method solves the problem.Because this code modification in JH, add a test case for it in JH.
-
devise.passwords.send_paranoid_instructions
: Reset password informationThis key can be successfully translated after loading
zh_CN.yml
.Just added a test case for it in this MR
-
Screenshots
Login failed | Recover password |
---|---|
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Closes #1347 (closed)