From ca5fcbc3b50b7853247161b5ab43b5e40e60e8b2 Mon Sep 17 00:00:00 2001 From: orozot Date: Sat, 20 Nov 2021 15:31:54 +0800 Subject: [PATCH 1/5] Fix: refactor some non-i18n components in issue page Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/346194 Changelog: fixed EE: true --- .../issuable/components/issuable_by_email.vue | 3 +-- .../issue_show/components/header_actions.vue | 15 +++++++++++++-- .../notes/components/comment_form.vue | 8 ++++---- app/assets/javascripts/notes/i18n.js | 10 ++++++++++ app/helpers/form_helper.rb | 2 +- .../issuables_description_templates_helper.rb | 2 +- app/helpers/issuables_helper.rb | 11 ++++++++--- app/views/projects/issues/_issue.html.haml | 6 +++--- .../projects/issues/_new_branch.html.haml | 2 +- .../merge_requests/_merge_request.html.haml | 3 +-- .../form_elements/_description.html.haml | 2 +- app/views/shared/issuable/_form.html.haml | 2 +- .../issuable/_milestone_dropdown.html.haml | 2 +- .../issuable/form/_default_templates.html.haml | 6 +++--- .../shared/issuable/form/_metadata.html.haml | 12 ++++++------ .../form/_metadata_issuable_assignee.html.haml | 2 +- .../issuable/form/_type_selector.html.haml | 2 +- .../shared/issuable/form/_weight.html.haml | 4 ++-- locale/gitlab.pot | 18 ++++++++++++++++++ 19 files changed, 77 insertions(+), 35 deletions(-) diff --git a/app/assets/javascripts/issuable/components/issuable_by_email.vue b/app/assets/javascripts/issuable/components/issuable_by_email.vue index 799d2bdc9e286b..512fa6f8c68d31 100644 --- a/app/assets/javascripts/issuable/components/issuable_by_email.vue +++ b/app/assets/javascripts/issuable/components/issuable_by_email.vue @@ -54,8 +54,7 @@ export default { data() { return { email: this.initialEmail, - // eslint-disable-next-line @gitlab/require-i18n-strings - issuableName: this.issuableType === 'issue' ? 'issue' : 'merge request', + issuableName: this.issuableType === 'issue' ? __('issue') : __('merge request'), }; }, computed: { diff --git a/app/assets/javascripts/issue_show/components/header_actions.vue b/app/assets/javascripts/issue_show/components/header_actions.vue index 2c314ce1c3fcb2..609a8364e9c1c2 100644 --- a/app/assets/javascripts/issue_show/components/header_actions.vue +++ b/app/assets/javascripts/issue_show/components/header_actions.vue @@ -78,10 +78,21 @@ export default { isClosed() { return this.openState === IssuableStatus.Closed; }, + issueTypeText() { + const issueTypeTexts = { + [IssuableType.Issue]: __('issue'), + [IssuableType.Incident]: __('incident'), + }; + + if (issueTypeTexts[this.issueType]) { + return issueTypeTexts[this.issueType]; + } + return this.issueType; + }, buttonText() { return this.isClosed - ? sprintf(__('Reopen %{issueType}'), { issueType: this.issueType }) - : sprintf(__('Close %{issueType}'), { issueType: this.issueType }); + ? sprintf(__('Reopen %{issueType}'), { issueType: this.issueTypeText }) + : sprintf(__('Close %{issueType}'), { issueType: this.issueTypeText }); }, qaSelector() { return this.isClosed ? 'reopen_issue_button' : 'close_issue_button'; diff --git a/app/assets/javascripts/notes/components/comment_form.vue b/app/assets/javascripts/notes/components/comment_form.vue index 4e31fdcd4f0691..69bd4d7130e190 100644 --- a/app/assets/javascripts/notes/components/comment_form.vue +++ b/app/assets/javascripts/notes/components/comment_form.vue @@ -105,14 +105,14 @@ export default { if (this.note.length) { return sprintf(this.$options.i18n.actionButtonWithNote, { actionText: this.commentButtonTitle, - openOrClose, - noteable: this.noteableDisplayName, + openOrClose: this.$options.i18n.openOrClose.lowercase[openOrClose], + noteable: this.issuableTypeTitle, }); } return sprintf(this.$options.i18n.actionButton, { - openOrClose: capitalizeFirstCharacter(openOrClose), - noteable: this.noteableDisplayName, + openOrClose: this.$options.i18n.openOrClose.capitalize[openOrClose], + noteable: this.issuableTypeTitle, }); }, actionButtonClassNames() { diff --git a/app/assets/javascripts/notes/i18n.js b/app/assets/javascripts/notes/i18n.js index 1ffb94d11adaf3..9d655ba2415f7c 100644 --- a/app/assets/javascripts/notes/i18n.js +++ b/app/assets/javascripts/notes/i18n.js @@ -23,4 +23,14 @@ export const COMMENT_FORM = { comment: __('Comment'), commentHelp: __('Add a general comment to this %{noteableDisplayName}.'), }, + openOrClose: { + lowercase: { + reopen: __('reopen'), + close: __('close'), + }, + capitalize: { + reopen: __('Reopen'), + close: __('Close'), + }, + }, }; diff --git a/app/helpers/form_helper.rb b/app/helpers/form_helper.rb index 9b4d0c0b9b334e..3bcf7cf1ca6bd6 100644 --- a/app/helpers/form_helper.rb +++ b/app/helpers/form_helper.rb @@ -45,7 +45,7 @@ def assignees_dropdown_options(issuable_type) current_user: true, project_id: (@target_project || @project)&.id, field_name: "#{issuable_type}[assignee_ids][]", - default_label: 'Unassigned', + default_label: _('Unassigned'), 'max-select': 1, 'dropdown-header': 'Assignee', multi_select: true, diff --git a/app/helpers/issuables_description_templates_helper.rb b/app/helpers/issuables_description_templates_helper.rb index 6b546d5c6fcad1..6c23f88882377b 100644 --- a/app/helpers/issuables_description_templates_helper.rb +++ b/app/helpers/issuables_description_templates_helper.rb @@ -6,7 +6,7 @@ module IssuablesDescriptionTemplatesHelper def template_dropdown_tag(issuable, &block) selected_template = selected_template(issuable) - title = selected_template || "Choose a template" + title = selected_template || _('Choose a template') options = { toggle_class: 'js-issuable-selector', title: title, diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index 07f5adae272b81..8596db1112107a 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -80,7 +80,7 @@ def serialize_issuable(issuable, opts = {}) def users_dropdown_label(selected_users) case selected_users.length when 0 - "Unassigned" + _('Unassigned') when 1 selected_users[0].name else @@ -141,7 +141,7 @@ def milestone_dropdown_label(milestone_title, default_label = "Milestone") else milestone_title.presence end - h(title || default_label) + h(title || _(default_label)) end def issuable_meta_author_status(author) @@ -188,7 +188,12 @@ def issuable_meta_author_slot(author, css_class: nil) end def issuables_state_counter_text(issuable_type, state, display_count) - titles = { opened: "Open" } + titles = { + opened: _("Open"), + closed: _("Closed"), + merged: _("Merged"), + all: _("All") + } state_title = titles[state] || state.to_s.humanize html = content_tag(:span, state_title) diff --git a/app/views/projects/issues/_issue.html.haml b/app/views/projects/issues/_issue.html.haml index 2de2c2cba6c79d..a2944584f94bc8 100644 --- a/app/views/projects/issues/_issue.html.haml +++ b/app/views/projects/issues/_issue.html.haml @@ -25,10 +25,10 @@ #{issuable_reference(issue)} %span.issuable-authored.d-none.d-sm-inline-block · - created #{time_ago_with_tooltip(issue.created_at, placement: 'bottom')} by - if issue.service_desk_reply_to - #{issue.service_desk_reply_to} via - #{link_to_member(@project, issue.author, avatar: false)} + #{_('created %{timeAgoString} by %{email} via %{user}').html_safe % { timeAgoString: time_ago_with_tooltip(issue.created_at, placement: 'bottom'), email: issue.service_desk_reply_to, user: link_to_member(@project, issue.author, avatar: false) }} + - else + #{s_('IssueList |created %{timeAgoString} by %{user}').html_safe % { timeAgoString: time_ago_with_tooltip(issue.created_at, placement: 'bottom'), user: link_to_member(@project, issue.author, avatar: false) }} = render_if_exists 'shared/issuable/gitlab_team_member_badge', author: issue.author - if issue.milestone %span.issuable-milestone.d-none.d-sm-inline-block diff --git a/app/views/projects/issues/_new_branch.html.haml b/app/views/projects/issues/_new_branch.html.haml index 07fec195899c02..1cf0551535babf 100644 --- a/app/views/projects/issues/_new_branch.html.haml +++ b/app/views/projects/issues/_new_branch.html.haml @@ -1,7 +1,7 @@ - if can?(current_user, :push_code, @project) - can_create_merge_request = can?(current_user, :create_merge_request_in, @project) - data_action = can_create_merge_request ? 'create-mr' : 'create-branch' - - value = can_create_merge_request ? 'Create merge request' : 'Create branch' + - value = can_create_merge_request ? _('Create merge request') : _('Create branch') - value = can_create_confidential_merge_request? ? _('Create confidential merge request') : value - create_mr_text = can_create_confidential_merge_request? ? _('Create confidential merge request') : _('Create merge request') diff --git a/app/views/projects/merge_requests/_merge_request.html.haml b/app/views/projects/merge_requests/_merge_request.html.haml index 3e2c5f088f7236..0116cf66a2a410 100644 --- a/app/views/projects/merge_requests/_merge_request.html.haml +++ b/app/views/projects/merge_requests/_merge_request.html.haml @@ -20,8 +20,7 @@ #{issuable_reference(merge_request)} %span.issuable-authored.d-none.d-sm-inline-block · - created #{time_ago_with_tooltip(merge_request.created_at, placement: 'bottom')} - by #{link_to_member(@project, merge_request.author, avatar: false)} + #{s_('IssueList |created %{timeAgoString} by %{user}').html_safe % { timeAgoString: time_ago_with_tooltip(merge_request.created_at, placement: 'bottom'), user: link_to_member(@project, merge_request.author, avatar: false) }} = render_if_exists 'shared/issuable/gitlab_team_member_badge', author: merge_request.author - if merge_request.milestone %span.issuable-milestone.d-none.d-sm-inline-block diff --git a/app/views/shared/form_elements/_description.html.haml b/app/views/shared/form_elements/_description.html.haml index f8942dddfb4e69..94818c13f76677 100644 --- a/app/views/shared/form_elements/_description.html.haml +++ b/app/views/shared/form_elements/_description.html.haml @@ -7,7 +7,7 @@ - preview_url = preview_markdown_path(project, target_type: model.class.name) .form-group.row.detail-page-description - = form.label :description, 'Description', class: 'col-form-label col-sm-2' + = form.label :description, _('Description'), class: 'col-form-label col-sm-2' .col-sm-10 - if model.is_a?(MergeRequest) = hidden_field_tag :merge_request_diff_head_sha, model.diff_head_sha diff --git a/app/views/shared/issuable/_form.html.haml b/app/views/shared/issuable/_form.html.haml index cb03bd4c473499..4024c5b77f609b 100644 --- a/app/views/shared/issuable/_form.html.haml +++ b/app/views/shared/issuable/_form.html.haml @@ -64,7 +64,7 @@ for this project. - if issuable.new_record? - = form.submit "Create #{issuable.class.model_name.human.downcase}", class: 'gl-button btn btn-confirm gl-mr-2', data: { qa_selector: 'issuable_create_button' } + = form.submit "#{_('Create')} #{issuable.class.model_name.human.downcase}", class: 'gl-button btn btn-confirm gl-mr-2', data: { qa_selector: 'issuable_create_button' } - else = form.submit _('Save changes'), class: 'gl-button btn btn-confirm gl-mr-2' diff --git a/app/views/shared/issuable/_milestone_dropdown.html.haml b/app/views/shared/issuable/_milestone_dropdown.html.haml index f58156b7c08f78..8cb51b7d8e3f90 100644 --- a/app/views/shared/issuable/_milestone_dropdown.html.haml +++ b/app/views/shared/issuable/_milestone_dropdown.html.haml @@ -8,7 +8,7 @@ - if selected.present? || params[:milestone_title].present? = hidden_field_tag(name, name == :milestone_title ? selected_text : selected.id) = dropdown_tag(milestone_dropdown_label(selected_text), options: { title: dropdown_title, toggle_class: "qa-issuable-milestone-dropdown js-milestone-select js-filter-submit #{extra_class}", filter: true, dropdown_class: "qa-issuable-dropdown-menu-milestone dropdown-menu-selectable dropdown-menu-milestone", - placeholder: "Search milestones", footer_content: project.present?, data: { show_no: true, show_menu_above: show_menu_above, show_any: show_any, show_upcoming: show_upcoming, show_started: show_started, field_name: name, selected: selected_text, project_id: project.try(:id), default_label: "Milestone" } }) do + placeholder: _('Search milestones'), footer_content: project.present?, data: { show_no: true, show_menu_above: show_menu_above, show_any: show_any, show_upcoming: show_upcoming, show_started: show_started, field_name: name, selected: selected_text, project_id: project.try(:id), default_label: "Milestone" } }) do - if project %ul.dropdown-footer-list - if can? current_user, :admin_milestone, project diff --git a/app/views/shared/issuable/form/_default_templates.html.haml b/app/views/shared/issuable/form/_default_templates.html.haml index 3dc244677e29aa..17bc206fb97d86 100644 --- a/app/views/shared/issuable/form/_default_templates.html.haml +++ b/app/views/shared/issuable/form/_default_templates.html.haml @@ -1,4 +1,4 @@ %p.form-text.text-muted - Add - = link_to 'description templates', help_page_path('user/project/description_templates') - to help your contributors communicate effectively! + = _('Add') + = link_to s_('Promotions|description templates'), help_page_path('user/project/description_templates') + = s_('Promotions|to help your contributors communicate effectively!') diff --git a/app/views/shared/issuable/form/_metadata.html.haml b/app/views/shared/issuable/form/_metadata.html.haml index 2f05d272ca3ae2..9e42c528a1147a 100644 --- a/app/views/shared/issuable/form/_metadata.html.haml +++ b/app/views/shared/issuable/form/_metadata.html.haml @@ -10,7 +10,7 @@ .form-check = form.check_box :confidential, class: 'form-check-input' = form.label :confidential, class: 'form-check-label' do - This issue is confidential and should only be visible to team members with at least Reporter access. + #{_('This issue is confidential and should only be visible to team members with at least Reporter access.')} - if can?(current_user, :"set_#{issuable.to_ability_name}_metadata", issuable) %hr @@ -27,13 +27,13 @@ - if issuable.supports_milestone? .form-group.row.issue-milestone - = form.label :milestone_id, "Milestone", class: "col-form-label #{has_due_date ? "col-md-2 col-lg-4" : "col-sm-2"}" + = form.label :milestone_id, _('Milestone'), class: "col-form-label #{has_due_date ? "col-md-2 col-lg-4" : "col-sm-2"}" .col-sm-10{ class: ("col-md-8" if has_due_date) } .issuable-form-select-holder - = render "shared/issuable/milestone_dropdown", selected: issuable.milestone, name: "#{issuable.class.model_name.param_key}[milestone_id]", show_any: false, show_upcoming: false, show_started: false, extra_class: "qa-issuable-milestone-dropdown js-issuable-form-dropdown js-dropdown-keep-input", dropdown_title: "Select milestone" + = render "shared/issuable/milestone_dropdown", selected: issuable.milestone, name: "#{issuable.class.model_name.param_key}[milestone_id]", show_any: false, show_upcoming: false, show_started: false, extra_class: "qa-issuable-milestone-dropdown js-issuable-form-dropdown js-dropdown-keep-input", dropdown_title: _('Select milestone') .form-group.row - = form.label :label_ids, "Labels", class: "col-form-label #{has_due_date ? "col-md-2 col-lg-4" : "col-sm-2"}" + = form.label :label_ids, _('Labels'), class: "col-form-label #{has_due_date ? "col-md-2 col-lg-4" : "col-sm-2"}" = form.hidden_field :label_ids, multiple: true, value: '' .col-sm-10{ class: "#{"col-md-8" if has_due_date}" } .issuable-form-select-holder @@ -45,7 +45,7 @@ .col-lg-6 = render_if_exists "shared/issuable/form/weight", issuable: issuable, form: form .form-group.row - = form.label :due_date, "Due date", class: "col-form-label col-md-2 col-lg-4" + = form.label :due_date, _('Due date'), class: "col-form-label col-md-2 col-lg-4" .col-8 .issuable-form-select-holder - = form.text_field :due_date, id: "issuable-due-date", class: "datepicker form-control", placeholder: "Select due date", autocomplete: 'off' + = form.text_field :due_date, id: "issuable-due-date", class: "datepicker form-control", placeholder: _('Select due date'), autocomplete: 'off' diff --git a/app/views/shared/issuable/form/_metadata_issuable_assignee.html.haml b/app/views/shared/issuable/form/_metadata_issuable_assignee.html.haml index b437ee1ec5f795..781ee8b5f8019b 100644 --- a/app/views/shared/issuable/form/_metadata_issuable_assignee.html.haml +++ b/app/views/shared/issuable/form/_metadata_issuable_assignee.html.haml @@ -8,4 +8,4 @@ = hidden_field_tag "#{issuable.to_ability_name}[assignee_ids][]", 0, id: nil, data: { meta: '' } = dropdown_tag(users_dropdown_label(issuable.assignees), options: assignees_dropdown_options(issuable.to_ability_name)) - = link_to 'Assign to me', '#', class: "assign-to-me-link qa-assign-to-me-link #{'hide' if issuable.assignees.include?(current_user)}" + = link_to _('Assign to me'), '#', class: "assign-to-me-link qa-assign-to-me-link #{'hide' if issuable.assignees.include?(current_user)}" diff --git a/app/views/shared/issuable/form/_type_selector.html.haml b/app/views/shared/issuable/form/_type_selector.html.haml index ae0fe54de4f064..0d86aa8c8e7d5d 100644 --- a/app/views/shared/issuable/form/_type_selector.html.haml +++ b/app/views/shared/issuable/form/_type_selector.html.haml @@ -1,7 +1,7 @@ - return unless issuable.supports_issue_type? && can?(current_user, :create_issue, @project) .form-group.row.gl-mb-0 - = form.label :type, 'Type', class: 'col-form-label col-sm-2' + = form.label :type, _('Type'), class: 'col-form-label col-sm-2' .col-sm-10 .gl-display-flex.gl-align-items-center .issuable-form-select-holder.selectbox.form-group.gl-mb-0 diff --git a/ee/app/views/shared/issuable/form/_weight.html.haml b/ee/app/views/shared/issuable/form/_weight.html.haml index b204abcf846a2e..9aa58a9b323d0b 100644 --- a/ee/app/views/shared/issuable/form/_weight.html.haml +++ b/ee/app/views/shared/issuable/form/_weight.html.haml @@ -7,10 +7,10 @@ .form-group.row = form.label :label_ids, class: "col-form-label col-md-2 #{"col-lg-4" if has_due_date}" do - Weight + #{_('Weight')} .col-md-10{ class: ("col-lg-8" if has_due_date) } .issuable-form-select-holder - if issuable.weight = form.hidden_field :weight - = form.text_field :weight, class: "datepicker form-control qa-issuable-weight-input", placeholder: "Enter a number", autocomplete: "off", type: "text" + = form.text_field :weight, class: "datepicker form-control qa-issuable-weight-input", placeholder: _('Enter a number'), autocomplete: "off", type: "text" diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 74049e27dacb17..9690dc2401cb27 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -4721,6 +4721,9 @@ msgstr "" msgid "Assign to commenting user" msgstr "" +msgid "Assign to me" +msgstr "" + msgid "Assign yourself to these issues" msgstr "" @@ -19407,6 +19410,9 @@ msgstr "" msgid "IssueBoards|Switch board" msgstr "" +msgid "IssueList |created %{timeAgoString} by %{user}" +msgstr "" + msgid "IssueTracker|Custom issue tracker" msgstr "" @@ -35576,6 +35582,9 @@ msgstr "" msgid "This is your current session" msgstr "" +msgid "This issue is confidential and should only be visible to team members with at least Reporter access." +msgstr "" + msgid "This issue is currently blocked by the following issues:" msgstr "" @@ -40918,6 +40927,9 @@ msgstr "" msgid "ciReport|is loading, errors when loading results" msgstr "" +msgid "close" +msgstr "" + msgid "closed" msgstr "" @@ -41259,6 +41271,9 @@ msgstr "" msgid "in project %{link_to_project}" msgstr "" +msgid "incident" +msgstr "" + msgid "instance completed" msgid_plural "instances completed" msgstr[0] "" @@ -42043,6 +42058,9 @@ msgstr "" msgid "rendered diff" msgstr "" +msgid "reopen" +msgstr "" + msgid "reply" msgid_plural "replies" msgstr[0] "" -- GitLab From 6525fef628c61bc379647bd917871e9c95f2e33c Mon Sep 17 00:00:00 2001 From: orozot Date: Thu, 25 Nov 2021 15:14:20 +0000 Subject: [PATCH 2/5] Update i18n msgid --- app/views/projects/issues/_issue.html.haml | 2 +- app/views/projects/merge_requests/_merge_request.html.haml | 2 +- locale/gitlab.pot | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/projects/issues/_issue.html.haml b/app/views/projects/issues/_issue.html.haml index a2944584f94bc8..6d848a1fbbee23 100644 --- a/app/views/projects/issues/_issue.html.haml +++ b/app/views/projects/issues/_issue.html.haml @@ -28,7 +28,7 @@ - if issue.service_desk_reply_to #{_('created %{timeAgoString} by %{email} via %{user}').html_safe % { timeAgoString: time_ago_with_tooltip(issue.created_at, placement: 'bottom'), email: issue.service_desk_reply_to, user: link_to_member(@project, issue.author, avatar: false) }} - else - #{s_('IssueList |created %{timeAgoString} by %{user}').html_safe % { timeAgoString: time_ago_with_tooltip(issue.created_at, placement: 'bottom'), user: link_to_member(@project, issue.author, avatar: false) }} + #{s_('IssueList|created %{timeAgoString} by %{user}').html_safe % { timeAgoString: time_ago_with_tooltip(issue.created_at, placement: 'bottom'), user: link_to_member(@project, issue.author, avatar: false) }} = render_if_exists 'shared/issuable/gitlab_team_member_badge', author: issue.author - if issue.milestone %span.issuable-milestone.d-none.d-sm-inline-block diff --git a/app/views/projects/merge_requests/_merge_request.html.haml b/app/views/projects/merge_requests/_merge_request.html.haml index 0116cf66a2a410..909615ede1e2d4 100644 --- a/app/views/projects/merge_requests/_merge_request.html.haml +++ b/app/views/projects/merge_requests/_merge_request.html.haml @@ -20,7 +20,7 @@ #{issuable_reference(merge_request)} %span.issuable-authored.d-none.d-sm-inline-block · - #{s_('IssueList |created %{timeAgoString} by %{user}').html_safe % { timeAgoString: time_ago_with_tooltip(merge_request.created_at, placement: 'bottom'), user: link_to_member(@project, merge_request.author, avatar: false) }} + #{s_('IssueList|created %{timeAgoString} by %{user}').html_safe % { timeAgoString: time_ago_with_tooltip(merge_request.created_at, placement: 'bottom'), user: link_to_member(@project, merge_request.author, avatar: false) }} = render_if_exists 'shared/issuable/gitlab_team_member_badge', author: merge_request.author - if merge_request.milestone %span.issuable-milestone.d-none.d-sm-inline-block diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 9690dc2401cb27..5cf4fb494cfc28 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -19410,7 +19410,7 @@ msgstr "" msgid "IssueBoards|Switch board" msgstr "" -msgid "IssueList |created %{timeAgoString} by %{user}" +msgid "IssueList|created %{timeAgoString} by %{user}" msgstr "" msgid "IssueTracker|Custom issue tracker" -- GitLab From a7a9c09e28bf980590b4dd5f35f6f62072378cdc Mon Sep 17 00:00:00 2001 From: orozot Date: Mon, 29 Nov 2021 19:07:10 +0800 Subject: [PATCH 3/5] Refactor epic and issue page to fix i18n display problem --- .../issue_show/components/header_actions.vue | 11 +++---- .../notes/components/comment_form.vue | 30 +++++++++---------- app/assets/javascripts/notes/i18n.js | 22 +++++++------- locale/gitlab.pot | 30 +++++++++++-------- 4 files changed, 48 insertions(+), 45 deletions(-) diff --git a/app/assets/javascripts/issue_show/components/header_actions.vue b/app/assets/javascripts/issue_show/components/header_actions.vue index 609a8364e9c1c2..e8cc105d23080d 100644 --- a/app/assets/javascripts/issue_show/components/header_actions.vue +++ b/app/assets/javascripts/issue_show/components/header_actions.vue @@ -7,7 +7,7 @@ import { IssuableType } from '~/issuable_show/constants'; import { IssuableStatus, IssueStateEvent } from '~/issue_show/constants'; import { capitalizeFirstCharacter } from '~/lib/utils/text_utility'; import { visitUrl } from '~/lib/utils/url_utility'; -import { __, sprintf } from '~/locale'; +import { s__, __, sprintf } from '~/locale'; import eventHub from '~/notes/event_hub'; import promoteToEpicMutation from '../queries/promote_to_epic.mutation.graphql'; import updateIssueMutation from '../queries/update_issue.mutation.graphql'; @@ -80,14 +80,11 @@ export default { }, issueTypeText() { const issueTypeTexts = { - [IssuableType.Issue]: __('issue'), - [IssuableType.Incident]: __('incident'), + [IssuableType.Issue]: s__('HeaderAction|issue'), + [IssuableType.Incident]: s__('HeaderAction|incident'), }; - if (issueTypeTexts[this.issueType]) { - return issueTypeTexts[this.issueType]; - } - return this.issueType; + return issueTypeTexts[this.issueType] ?? this.issueType; }, buttonText() { return this.isClosed diff --git a/app/assets/javascripts/notes/components/comment_form.vue b/app/assets/javascripts/notes/components/comment_form.vue index 69bd4d7130e190..996c008b881573 100644 --- a/app/assets/javascripts/notes/components/comment_form.vue +++ b/app/assets/javascripts/notes/components/comment_form.vue @@ -11,7 +11,6 @@ import httpStatusCodes from '~/lib/utils/http_status'; import { capitalizeFirstCharacter, convertToCamelCase, - splitCamelCase, slugifyWithUnderscore, } from '~/lib/utils/text_utility'; import { sprintf } from '~/locale'; @@ -77,7 +76,15 @@ export default { ]), ...mapState(['isToggleStateButtonLoading']), noteableDisplayName() { - return splitCamelCase(this.noteableType).toLowerCase(); + const displayNameMap = { + [constants.ISSUE_NOTEABLE_TYPE]: this.$options.i18n.issue, + [constants.EPIC_NOTEABLE_TYPE]: this.$options.i18n.epic, + [constants.MERGE_REQUEST_NOTEABLE_TYPE]: this.$options.i18n.mergeRequest, + }; + + const noteableTypeKey = + constants.NOTEABLE_TYPE_MAPPING[this.noteableType] || constants.ISSUE_NOTEABLE_TYPE; + return displayNameMap[noteableTypeKey]; }, isLoggedIn() { return this.getUserData.id; @@ -103,16 +110,14 @@ export default { const openOrClose = this.isOpen ? 'close' : 'reopen'; if (this.note.length) { - return sprintf(this.$options.i18n.actionButtonWithNote, { + return sprintf(this.$options.i18n.actionButton.withNote[openOrClose], { actionText: this.commentButtonTitle, - openOrClose: this.$options.i18n.openOrClose.lowercase[openOrClose], - noteable: this.issuableTypeTitle, + noteable: this.noteableDisplayName, }); } - return sprintf(this.$options.i18n.actionButton, { - openOrClose: this.$options.i18n.openOrClose.capitalize[openOrClose], - noteable: this.issuableTypeTitle, + return sprintf(this.$options.i18n.actionButton.withoutNote[openOrClose], { + noteable: this.noteableDisplayName, }); }, actionButtonClassNames() { @@ -151,13 +156,8 @@ export default { draftEndpoint() { return this.getNotesData.draftsPath; }, - issuableTypeTitle() { - return this.noteableType === constants.MERGE_REQUEST_NOTEABLE_TYPE - ? this.$options.i18n.mergeRequest - : this.$options.i18n.issue; - }, isIssue() { - return this.noteableDisplayName === constants.ISSUE_NOTEABLE_TYPE; + return constants.NOTEABLE_TYPE_MAPPING[this.noteableType] === constants.ISSUE_NOTEABLE_TYPE; }, trackingLabel() { return slugifyWithUnderscore(`${this.commentButtonTitle} button`); @@ -329,7 +329,7 @@ export default {