Fix: notify locale on push to merge request email
requested to merge gitlab-jh/jh-team/gitlab:fix/notify-locale-on-push-to-merge-request-email into master
What does this MR do and why?
Reason
Right now the email template for push to merge request email notification can only be sent in English
Result
in this MR I updated the template with i18n enabled strings instead of hardcoded strings. After this MR it will be able to send languages the user prefers.
How to test locally
- Start your GDK instance locally or via gitpod or other ways
- Run rails console
recipient=User.find(1) merge_request=MergeRequest.find(1) push_user=recipient existing_commits=[merge_request.commits.first] Notify.push_to_merge_request_email( recipient.id, merge_request.id, push_user.id, new_commits: merge_request.commits, total_new_commits_count: merge_request.commits.length+3, existing_commits: existing_commits, total_existing_commits_count: existing_commits.length ).deliver
- See before version on http://127.0.0.1:3000/rails/letter_opener/
- Set
:zh_CN
- Add
- I18n.locale = :zh_CN
forapp/views/notify/push_to_merge_request_email.html.haml
- Copy the text and paste it into
locale/zh_CN/gitlab.po
msgid "Notify|%{updated_by_user_name} pushed new commits to merge request %{mr_link}" msgstr "%{updated_by_user_name} 将新提交推送到合并请求 %{mr_link}" msgid "#%d commit" msgid_plural "#%d commits" msgstr[0] "%d 个提交" msgid "%{commits_text} from branch `%{target_branch}`" msgstr "%{commits_text} 来自分支 `%{target_branch}`" msgid "Notify|And %{total_stripped_new_commits_count} more" msgstr "还有 %{total_stripped_new_commits_count} 个"
- Add
- Repeat 2 and 3 to see after
/cc @prajnamas @orozot @qk44077907 @JeremyWuuuuu
Screenshots or screen recordings
Before | After |
---|---|
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.
Edited by qt