From 205eddc77721bb2b99378cec4a0978baea252573 Mon Sep 17 00:00:00 2001 From: Brandon Labuschagne Date: Wed, 1 May 2019 15:54:18 +0000 Subject: Internationalisation of notes directory This is one of many MRs opened in order to improve the overall internationalisation of the GitLab codebase. i18n documentation https://docs.gitlab.com/ee/development/i18n/externalization.html --- app/assets/javascripts/notes/mixins/autosave.js | 3 ++- app/assets/javascripts/notes/stores/actions.js | 8 ++++---- app/assets/javascripts/notes/stores/utils.js | 7 ++++--- 3 files changed, 10 insertions(+), 8 deletions(-) (limited to 'app/assets') diff --git a/app/assets/javascripts/notes/mixins/autosave.js b/app/assets/javascripts/notes/mixins/autosave.js index 4f45f912479..b161773f5f1 100644 --- a/app/assets/javascripts/notes/mixins/autosave.js +++ b/app/assets/javascripts/notes/mixins/autosave.js @@ -1,12 +1,13 @@ import $ from 'jquery'; import Autosave from '../../autosave'; import { capitalizeFirstCharacter } from '../../lib/utils/text_utility'; +import { s__ } from '~/locale'; export default { methods: { initAutoSave(noteable, extraKeys = []) { let keys = [ - 'Note', + s__('Autosave|Note'), capitalizeFirstCharacter(noteable.noteable_type || noteable.noteableType), noteable.id, ]; diff --git a/app/assets/javascripts/notes/stores/actions.js b/app/assets/javascripts/notes/stores/actions.js index 1a0dba69a7c..970e6551092 100644 --- a/app/assets/javascripts/notes/stores/actions.js +++ b/app/assets/javascripts/notes/stores/actions.js @@ -255,7 +255,7 @@ export const saveNote = ({ commit, dispatch }, noteData) => { eTagPoll.makeRequest(); $('.js-gfm-input').trigger('clear-commands-cache.atwho'); - Flash('Commands applied', 'notice', noteData.flashContainer); + Flash(__('Commands applied'), 'notice', noteData.flashContainer); } if (commandsChanges) { @@ -269,7 +269,7 @@ export const saveNote = ({ commit, dispatch }, noteData) => { }) .catch(() => { Flash( - 'Something went wrong while adding your award. Please try again.', + __('Something went wrong while adding your award. Please try again.'), 'alert', noteData.flashContainer, ); @@ -311,7 +311,7 @@ export const poll = ({ commit, state, getters, dispatch }) => { data: state, successCallback: resp => resp.json().then(data => pollSuccessCallBack(data, commit, state, getters, dispatch)), - errorCallback: () => Flash('Something went wrong while fetching latest comments.'), + errorCallback: () => Flash(__('Something went wrong while fetching latest comments.')), }); if (!Visibility.hidden()) { @@ -347,7 +347,7 @@ export const fetchData = ({ commit, state, getters }) => { .poll(requestData) .then(resp => resp.json) .then(data => pollSuccessCallBack(data, commit, state, getters)) - .catch(() => Flash('Something went wrong while fetching latest comments.')); + .catch(() => Flash(__('Something went wrong while fetching latest comments.'))); }; export const toggleAward = ({ commit, getters }, { awardName, noteId }) => { diff --git a/app/assets/javascripts/notes/stores/utils.js b/app/assets/javascripts/notes/stores/utils.js index 4b0feb0f94d..029fde348fb 100644 --- a/app/assets/javascripts/notes/stores/utils.js +++ b/app/assets/javascripts/notes/stores/utils.js @@ -1,12 +1,13 @@ import AjaxCache from '~/lib/utils/ajax_cache'; import { trimFirstCharOfLineContent } from '~/diffs/store/utils'; +import { sprintf, __ } from '~/locale'; const REGEX_QUICK_ACTIONS = /^\/\w+.*$/gm; export const findNoteObjectById = (notes, id) => notes.filter(n => n.id === id)[0]; export const getQuickActionText = note => { - let text = 'Applying command'; + let text = __('Applying command'); const quickActions = AjaxCache.get(gl.GfmAutoComplete.dataSources.commands) || []; const executedCommands = quickActions.filter(command => { @@ -16,10 +17,10 @@ export const getQuickActionText = note => { if (executedCommands && executedCommands.length) { if (executedCommands.length > 1) { - text = 'Applying multiple commands'; + text = __('Applying multiple commands'); } else { const commandDescription = executedCommands[0].description.toLowerCase(); - text = `Applying command to ${commandDescription}`; + text = sprintf(__('Applying command to %{commandDescription}', { commandDescription })); } } -- cgit v1.2.1