Commit e84e4fdd authored by Phil Hughes's avatar Phil Hughes

added i18n methods

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