Commit e84e4fdd authored by Phil Hughes's avatar Phil Hughes

added i18n methods

parent 89f3be09
<script> <script>
import { mapState } from 'vuex'; import { mapState } from 'vuex';
import { sprintf, __ } from '../../../locale';
import * as consts from '../../stores/modules/commit/constants'; import * as consts from '../../stores/modules/commit/constants';
import RadioGroup from './radio_group.vue'; import RadioGroup from './radio_group.vue';
...@@ -19,7 +20,23 @@ ...@@ -19,7 +20,23 @@
'currentBranchId', 'currentBranchId',
]), ]),
newMergeRequestHelpText() { newMergeRequestHelpText() {
return `Creates a new branch from ${this.currentBranchId} and re-directs to create a new merge request`; return sprintf(
__(`Creates a new branch from %{branchName} and re-directs to create a new merge request`),
{ branchName: this.currentBranchId },
);
},
commitToCurrentBranchText() {
return sprintf(
__('Commit to %{branchName} branch'),
{ branchName: `<strong>${this.currentBranchId}</strong>` },
false,
)
},
commitToNewBranchText() {
return sprintf(
__('Creates a new branch from %{branchName}'),
{ branchName: this.currentBranchId },
);
}, },
}, },
}; };
...@@ -32,7 +49,7 @@ ...@@ -32,7 +49,7 @@
:checked="true" :checked="true"
> >
<span <span
v-html="`Commit to <strong>${currentBranchId}</strong> branch`" v-html="commitToCurrentBranchText"
> >
</span> </span>
</radio-group> </radio-group>
...@@ -40,7 +57,7 @@ ...@@ -40,7 +57,7 @@
:value="COMMIT_TO_NEW_BRANCH" :value="COMMIT_TO_NEW_BRANCH"
label="Create a new branch" label="Create a new branch"
:show-input="true" :show-input="true"
:help-text="`Creates a new branch from ${currentBranchId}`" :help-text="commitToNewBranchText"
/> />
<radio-group <radio-group
:value="COMMIT_TO_NEW_BRANCH_MR" :value="COMMIT_TO_NEW_BRANCH_MR"
......
...@@ -113,7 +113,7 @@ export default { ...@@ -113,7 +113,7 @@ export default {
class="form-control input-sm multi-file-commit-message" class="form-control input-sm multi-file-commit-message"
name="commit-message" name="commit-message"
:value="commitMessage" :value="commitMessage"
placeholder="Write a commit message..." :placeholder="__('Write a commit message...')"
@input="updateCommitMessage($event.target.value)" @input="updateCommitMessage($event.target.value)"
> >
</textarea> </textarea>
......
import { sprintf, __ } from '../../../../locale';
import * as types from './mutation_types'; import * as types from './mutation_types';
import * as consts from './constants'; import * as consts from './constants';
import * as rootTypes from '../../mutation_types'; import * as rootTypes from '../../mutation_types';
...@@ -25,11 +26,19 @@ export const updateBranchName = ({ commit }, branchName) => { ...@@ -25,11 +26,19 @@ export const updateBranchName = ({ commit }, branchName) => {
}; };
export const setLastCommitMessage = ({ commit }, data) => { export const setLastCommitMessage = ({ commit }, data) => {
let commitMsg = `Your changes have been committed. Commit ${data.short_id}`; const commitStats = data.stats ?
sprintf(
if (data.stats) { __('with %{additions} additions, %{deletions} deletions.'),
commitMsg += ` with ${data.stats.additions} additions, ${data.stats.deletions} deletions.`; { additions: data.stats.additions, deletions: data.stats.deletions },
} )
: '';
const commitMsg = sprintf(
__('Your changes have been committed. Commit %{commitId} %{commitStats}'),
{
commmitId: data.short_id,
commitStats,
},
);
commit(rootTypes.SET_LAST_COMMIT_MSG, commitMsg, { root: true }); commit(rootTypes.SET_LAST_COMMIT_MSG, commitMsg, { root: true });
}; };
...@@ -48,7 +57,7 @@ export const checkCommitStatus = ({ rootState }) => ...@@ -48,7 +57,7 @@ export const checkCommitStatus = ({ rootState }) =>
return false; return false;
}) })
.catch(() => flash('Error checking branch data. Please try again.', 'alert', document, null, false, true)); .catch(() => flash(__('Error checking branch data. Please try again.'), 'alert', document, null, false, true));
export const updateFilesAfterCommit = ( export const updateFilesAfterCommit = (
{ commit, dispatch, state, rootState, rootGetters }, { commit, dispatch, state, rootState, rootGetters },
...@@ -135,7 +144,7 @@ export const commitChanges = ({ commit, state, getters, dispatch, rootState }) = ...@@ -135,7 +144,7 @@ export const commitChanges = ({ commit, state, getters, dispatch, rootState }) =
} }
}) })
.catch((err) => { .catch((err) => {
let errMsg = 'Error committing changes. Please try again.'; let errMsg = __('Error committing changes. Please try again.');
if (err.response.data && err.response.data.message) { if (err.response.data && err.response.data.message) {
errMsg += ` (${stripHtml(err.response.data.message)})`; errMsg += ` (${stripHtml(err.response.data.message)})`;
} }
......
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