Commit 21e1da36 authored by Andrew Fontaine's avatar Andrew Fontaine

Merge branch 'tor/defect/network-error-message/i18n-cleanup' into 'master'

Move i18n for Comment Form component to Notes app I18n file

See merge request gitlab-org/gitlab!55427
parents 128748c2 f66b4a94
...@@ -20,12 +20,15 @@ import { ...@@ -20,12 +20,15 @@ import {
splitCamelCase, splitCamelCase,
slugifyWithUnderscore, slugifyWithUnderscore,
} from '~/lib/utils/text_utility'; } from '~/lib/utils/text_utility';
import { __, sprintf } from '~/locale'; import { sprintf } from '~/locale';
import markdownField from '~/vue_shared/components/markdown/field.vue'; import markdownField from '~/vue_shared/components/markdown/field.vue';
import TimelineEntryItem from '~/vue_shared/components/notes/timeline_entry_item.vue'; import TimelineEntryItem from '~/vue_shared/components/notes/timeline_entry_item.vue';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import * as constants from '../constants'; import * as constants from '../constants';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
import { COMMENT_FORM } from '../i18n';
import issuableStateMixin from '../mixins/issuable_state'; import issuableStateMixin from '../mixins/issuable_state';
import CommentFieldLayout from './comment_field_layout.vue'; import CommentFieldLayout from './comment_field_layout.vue';
import discussionLockedWidget from './discussion_locked_widget.vue'; import discussionLockedWidget from './discussion_locked_widget.vue';
...@@ -33,13 +36,7 @@ import noteSignedOutWidget from './note_signed_out_widget.vue'; ...@@ -33,13 +36,7 @@ import noteSignedOutWidget from './note_signed_out_widget.vue';
export default { export default {
name: 'CommentForm', name: 'CommentForm',
i18n: { i18n: COMMENT_FORM,
submitButton: {
startThread: __('Start thread'),
comment: __('Comment'),
commentHelp: __('Add a general comment to this %{noteableDisplayName}.'),
},
},
noteTypeComment: constants.COMMENT, noteTypeComment: constants.COMMENT,
noteTypeDiscussion: constants.DISCUSSION, noteTypeDiscussion: constants.DISCUSSION,
components: { components: {
...@@ -96,12 +93,14 @@ export default { ...@@ -96,12 +93,14 @@ export default {
return this.getUserData.id; return this.getUserData.id;
}, },
commentButtonTitle() { commentButtonTitle() {
return this.noteType === constants.COMMENT ? __('Comment') : __('Start thread'); return this.noteType === constants.COMMENT
? this.$options.i18n.comment
: this.$options.i18n.startThread;
}, },
startDiscussionDescription() { startDiscussionDescription() {
return this.getNoteableData.noteableType === constants.MERGE_REQUEST_NOTEABLE_TYPE return this.getNoteableData.noteableType === constants.MERGE_REQUEST_NOTEABLE_TYPE
? __('Discuss a specific suggestion or question that needs to be resolved.') ? this.$options.i18n.discussionThatNeedsResolution
: __('Discuss a specific suggestion or question.'); : this.$options.i18n.discussion;
}, },
commentDescription() { commentDescription() {
return sprintf(this.$options.i18n.submitButton.commentHelp, { return sprintf(this.$options.i18n.submitButton.commentHelp, {
...@@ -121,14 +120,14 @@ export default { ...@@ -121,14 +120,14 @@ export default {
const openOrClose = this.isOpen ? 'close' : 'reopen'; const openOrClose = this.isOpen ? 'close' : 'reopen';
if (this.note.length) { if (this.note.length) {
return sprintf(__('%{actionText} & %{openOrClose} %{noteable}'), { return sprintf(this.$options.i18n.actionButtonWithNote, {
actionText: this.commentButtonTitle, actionText: this.commentButtonTitle,
openOrClose, openOrClose,
noteable: this.noteableDisplayName, noteable: this.noteableDisplayName,
}); });
} }
return sprintf(__('%{openOrClose} %{noteable}'), { return sprintf(this.$options.i18n.actionButton, {
openOrClose: capitalizeFirstCharacter(openOrClose), openOrClose: capitalizeFirstCharacter(openOrClose),
noteable: this.noteableDisplayName, noteable: this.noteableDisplayName,
}); });
...@@ -171,8 +170,8 @@ export default { ...@@ -171,8 +170,8 @@ export default {
}, },
issuableTypeTitle() { issuableTypeTitle() {
return this.noteableType === constants.MERGE_REQUEST_NOTEABLE_TYPE return this.noteableType === constants.MERGE_REQUEST_NOTEABLE_TYPE
? __('merge request') ? this.$options.i18n.mergeRequest
: __('issue'); : this.$options.i18n.issue;
}, },
isIssue() { isIssue() {
return this.noteableDisplayName === constants.ISSUE_NOTEABLE_TYPE; return this.noteableDisplayName === constants.ISSUE_NOTEABLE_TYPE;
...@@ -242,9 +241,7 @@ export default { ...@@ -242,9 +241,7 @@ export default {
}) })
.catch(() => { .catch(() => {
this.discard(false); this.discard(false);
const msg = __( const msg = this.$options.i18n.GENERIC_UNSUBMITTABLE_NETWORK;
'Your comment could not be submitted! Please check your network connection and try again.',
);
Flash(msg, 'alert', this.$el); Flash(msg, 'alert', this.$el);
this.note = noteData.data.note.note; // Restore textarea content. this.note = noteData.data.note.note; // Restore textarea content.
this.removePlaceholderNotes(); this.removePlaceholderNotes();
...@@ -310,7 +307,7 @@ export default { ...@@ -310,7 +307,7 @@ export default {
const noteableType = capitalizeFirstCharacter(convertToCamelCase(this.noteableType)); const noteableType = capitalizeFirstCharacter(convertToCamelCase(this.noteableType));
this.autosave = new Autosave($(this.$refs.textarea), [ this.autosave = new Autosave($(this.$refs.textarea), [
__('Note'), this.$options.i18n.note,
noteableType, noteableType,
this.getNoteableData.id, this.getNoteableData.id,
]); ]);
...@@ -363,8 +360,8 @@ export default { ...@@ -363,8 +360,8 @@ export default {
data-qa-selector="comment_field" data-qa-selector="comment_field"
data-testid="comment-field" data-testid="comment-field"
:data-supports-quick-actions="!glFeatures.tributeAutocomplete" :data-supports-quick-actions="!glFeatures.tributeAutocomplete"
:aria-label="__('Comment')" :aria-label="$options.i18n.comment"
:placeholder="__('Write a comment or drag your files here…')" :placeholder="$options.i18n.bodyPlaceholder"
@keydown.up="editCurrentUserLastNote()" @keydown.up="editCurrentUserLastNote()"
@keydown.meta.enter="handleSave()" @keydown.meta.enter="handleSave()"
@keydown.ctrl.enter="handleSave()" @keydown.ctrl.enter="handleSave()"
...@@ -379,12 +376,12 @@ export default { ...@@ -379,12 +376,12 @@ export default {
class="gl-mb-6" class="gl-mb-6"
data-testid="confidential-note-checkbox" data-testid="confidential-note-checkbox"
> >
{{ s__('Notes|Make this comment confidential') }} {{ $options.i18n.confidential }}
<gl-icon <gl-icon
v-gl-tooltip:tooltipcontainer.bottom v-gl-tooltip:tooltipcontainer.bottom
name="question" name="question"
:size="16" :size="16"
:title="s__('Notes|Confidential comments are only visible to project members')" :title="$options.i18n.confidentialVisibility"
class="gl-text-gray-500" class="gl-text-gray-500"
/> />
</gl-form-checkbox> </gl-form-checkbox>
......
import { __, s__ } from '~/locale';
export const COMMENT_FORM = {
GENERIC_UNSUBMITTABLE_NETWORK: __(
'Your comment could not be submitted! Please check your network connection and try again.',
),
note: __('Note'),
comment: __('Comment'),
issue: __('issue'),
startThread: __('Start thread'),
mergeRequest: __('merge request'),
bodyPlaceholder: __('Write a comment or drag your files here…'),
confidential: s__('Notes|Make this comment confidential'),
confidentialVisibility: s__('Notes|Confidential comments are only visible to project members'),
discussionThatNeedsResolution: __(
'Discuss a specific suggestion or question that needs to be resolved.',
),
discussion: __('Discuss a specific suggestion or question.'),
actionButtonWithNote: __('%{actionText} & %{openOrClose} %{noteable}'),
actionButton: __('%{openOrClose} %{noteable}'),
submitButton: {
startThread: __('Start thread'),
comment: __('Comment'),
commentHelp: __('Add a general comment to this %{noteableDisplayName}.'),
},
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment