Skip to content

Resolve "Devise i18n support"

奇廷 陈请求将1347-devise-i18n-support合并到main-jh

upstream MR

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 in config/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 message

      This key cannot be translated correctly because it belongs to the devise error message, generated by FailureApp#respond under the devise gem. And FailureApp Controller inherits from ActionController::Metal instead of ApplicationController, so the respond action is not covered by set_locale.The design.failure.invalid key is translated by default_locale(:en).

      Solution in this MR : FailureApp#respond gets the message through the i18n_message method, which is overridden by JH. So make set_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 information

      This 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
image image

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Closes #1347 (closed)

Fu Zhang 编辑于

合并请求报告

加载中