Commit c51a9306 authored by Phil Hughes's avatar Phil Hughes

updates to template text to be i18n ready

parent 2aaa0222
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import tooltip from '~/vue_shared/directives/tooltip'; import tooltip from '~/vue_shared/directives/tooltip';
import icon from '~/vue_shared/components/icon.vue'; import icon from '~/vue_shared/components/icon.vue';
import { pluralize } from '~/lib/utils/text_utility'; import { pluralize } from '~/lib/utils/text_utility';
import { __, sprintf } from '~/locale';
export default { export default {
components: { components: {
...@@ -34,11 +35,17 @@ export default { ...@@ -34,11 +35,17 @@ export default {
const type = this.file.tempFile ? 'addition' : 'modification'; const type = this.file.tempFile ? 'addition' : 'modification';
if (this.file.changed && !this.file.staged) { if (this.file.changed && !this.file.staged) {
return `Unstaged ${type}`; return sprintf(__('Unstaged %{type}'), {
type,
});
} else if (!this.file.changed && this.file.staged) { } else if (!this.file.changed && this.file.staged) {
return `Staged ${type}`; return sprintf(__('Staged %{type}'), {
type,
});
} else if (this.file.changed && this.file.staged) { } else if (this.file.changed && this.file.staged) {
return `Unstaged and staged ${pluralize(type)}`; return sprintf(__('Unstaged and staged %{type}'), {
type: pluralize(type),
});
} }
return undefined; return undefined;
......
<script> <script>
import { mapActions, mapState, mapGetters } from 'vuex'; import { mapActions, mapState, mapGetters } from 'vuex';
import icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import tooltip from '~/vue_shared/directives/tooltip'; import tooltip from '~/vue_shared/directives/tooltip';
import listItem from './list_item.vue'; import ListItem from './list_item.vue';
import listCollapsed from './list_collapsed.vue'; import ListCollapsed from './list_collapsed.vue';
import { __, sprintf } from '~/locale';
export default { export default {
components: { components: {
icon, Icon,
listItem, ListItem,
listCollapsed, ListCollapsed,
}, },
directives: { directives: {
tooltip, tooltip,
...@@ -48,6 +49,11 @@ export default { ...@@ -48,6 +49,11 @@ export default {
computed: { computed: {
...mapState(['rightPanelCollapsed']), ...mapState(['rightPanelCollapsed']),
...mapGetters(['collapseButtonIcon', 'collapseButtonTooltip']), ...mapGetters(['collapseButtonIcon', 'collapseButtonTooltip']),
titleText() {
return sprintf(__('%{title} changes'), {
title: this.title,
});
},
}, },
methods: { methods: {
...mapActions(['toggleRightPanelCollapsed', 'stageAllChanges', 'unstageAllChanges']), ...mapActions(['toggleRightPanelCollapsed', 'stageAllChanges', 'unstageAllChanges']),
...@@ -83,7 +89,7 @@ export default { ...@@ -83,7 +89,7 @@ export default {
:name="icon" :name="icon"
:size="18" :size="18"
/> />
{{ title }} changes {{ titleText }}
<button <button
type="button" type="button"
class="btn btn-blank btn-link ide-staged-action-btn" class="btn btn-blank btn-link ide-staged-action-btn"
......
<script> <script>
import icon from '~/vue_shared/components/icon.vue'; import icon from '~/vue_shared/components/icon.vue';
import tooltip from '~/vue_shared/directives/tooltip'; import tooltip from '~/vue_shared/directives/tooltip';
import { sprintf, n__ } from '~/locale'; import { sprintf, n__, __ } from '~/locale';
export default { export default {
components: { components: {
...@@ -38,27 +38,18 @@ export default { ...@@ -38,27 +38,18 @@ export default {
return this.modifiedFilesLength ? 'multi-file-modified' : ''; return this.modifiedFilesLength ? 'multi-file-modified' : '';
}, },
additionsTooltip() { additionsTooltip() {
return sprintf( return sprintf(n__('1 %{type} addition', '%d %{type} additions', this.addedFilesLength), {
n__( type: this.title.toLowerCase(),
'1 %{type} addition', });
'%d %{type} additions',
this.addedFilesLength,
),
{ type: this.title.toLowerCase() },
);
}, },
modifiedTooltip() { modifiedTooltip() {
return sprintf( return sprintf(
n__( n__('1 %{type} modification', '%d %{type} modifications', this.modifiedFilesLength),
'1 %{type} modification',
'%d %{type} modifications',
this.modifiedFilesLength,
),
{ type: this.title.toLowerCase() }, { type: this.title.toLowerCase() },
); );
}, },
titleTooltip() { titleTooltip() {
return `${this.title} changes`; return sprintf(__('%{title} changes'), { title: this.title });
}, },
}, },
}; };
......
import { __ } from '~/locale';
export const activeFile = state => state.openFiles.find(file => file.active) || null; export const activeFile = state => state.openFiles.find(file => file.active) || null;
export const addedFiles = state => state.changedFiles.filter(f => f.tempFile); export const addedFiles = state => state.changedFiles.filter(f => f.tempFile);
...@@ -36,6 +38,6 @@ export const hasChanges = state => !!state.changedFiles.length || !!state.staged ...@@ -36,6 +38,6 @@ export const hasChanges = state => !!state.changedFiles.length || !!state.staged
// eslint-disable-next-line no-confusing-arrow // eslint-disable-next-line no-confusing-arrow
export const collapseButtonTooltip = state => export const collapseButtonTooltip = state =>
state.rightPanelCollapsed ? 'Expand sidebar' : 'Collapse sidebar'; state.rightPanelCollapsed ? __('Expand sidebar') : __('Collapse sidebar');
export const hasMergeRequest = state => !!state.currentMergeRequestId; export const hasMergeRequest = state => !!state.currentMergeRequestId;
import * as consts from './constants'; import * as consts from './constants';
const BRANCH_SUFFIX_COUNT = 5;
export const discardDraftButtonDisabled = state => export const discardDraftButtonDisabled = state =>
state.commitMessage === '' || state.submitCommitLoading; state.commitMessage === '' || state.submitCommitLoading;
...@@ -8,7 +10,7 @@ export const commitButtonDisabled = (state, getters, rootState) => ...@@ -8,7 +10,7 @@ export const commitButtonDisabled = (state, getters, rootState) =>
export const newBranchName = (state, _, rootState) => export const newBranchName = (state, _, rootState) =>
`${gon.current_username}-${rootState.currentBranchId}-patch-${`${new Date().getTime()}`.substr( `${gon.current_username}-${rootState.currentBranchId}-patch-${`${new Date().getTime()}`.substr(
-5, -BRANCH_SUFFIX_COUNT,
)}`; )}`;
export const branchName = (state, getters, rootState) => { export const branchName = (state, getters, rootState) => {
......
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