I18N JS files starting with u

This is one of many MRs opened in order to improve the overall
internationalisation of the GitLab codebase.

This commit only targets Vanilla JS files.

i18n documentation
https://docs.gitlab.com/ee/development/i18n/externalization.html
This commit is contained in:
Brandon Labuschagne 2019-05-07 14:00:52 +02:00
parent f59a63115e
commit d4ed2f74e3
3 changed files with 50 additions and 15 deletions

View file

@ -2,6 +2,7 @@ import $ from 'jquery';
import axios from './lib/utils/axios_utils'; import axios from './lib/utils/axios_utils';
import Flash, { hideFlash } from './flash'; import Flash, { hideFlash } from './flash';
import { parseBoolean } from './lib/utils/common_utils'; import { parseBoolean } from './lib/utils/common_utils';
import { __ } from './locale';
export default () => { export default () => {
$('body').on('click', '.js-usage-consent-action', e => { $('body').on('click', '.js-usage-consent-action', e => {
@ -25,7 +26,7 @@ export default () => {
}) })
.catch(() => { .catch(() => {
hideConsentMessage(); hideConsentMessage();
Flash('Something went wrong. Try again later.'); Flash(__('Something went wrong. Try again later.'));
}); });
}); });
}; };

View file

@ -5,7 +5,7 @@
import $ from 'jquery'; import $ from 'jquery';
import _ from 'underscore'; import _ from 'underscore';
import axios from './lib/utils/axios_utils'; import axios from './lib/utils/axios_utils';
import { __ } from './locale'; import { s__, __, sprintf } from './locale';
import ModalStore from './boards/stores/modal_store'; import ModalStore from './boards/stores/modal_store';
// TODO: remove eventHub hack after code splitting refactor // TODO: remove eventHub hack after code splitting refactor
@ -157,14 +157,20 @@ function UsersSelect(currentUser, els, options = {}) {
.get(0); .get(0);
if (selectedUsers.length === 0) { if (selectedUsers.length === 0) {
return 'Unassigned'; return s__('UsersSelect|Unassigned');
} else if (selectedUsers.length === 1) { } else if (selectedUsers.length === 1) {
return firstUser.name; return firstUser.name;
} else if (isSelected) { } else if (isSelected) {
const otherSelected = selectedUsers.filter(s => s !== selectedUser.id); const otherSelected = selectedUsers.filter(s => s !== selectedUser.id);
return `${selectedUser.name} + ${otherSelected.length} more`; return sprintf(s__('UsersSelect|%{name} + %{length} more'), {
name: selectedUser.name,
length: otherSelected.length,
});
} else { } else {
return `${firstUser.name} + ${selectedUsers.length - 1} more`; return sprintf(s__('UsersSelect|%{name} + %{length} more'), {
name: firstUser.name,
length: selectedUsers.length - 1,
});
} }
}; };
@ -218,11 +224,11 @@ function UsersSelect(currentUser, els, options = {}) {
tooltipTitle = _.escape(user.name); tooltipTitle = _.escape(user.name);
} else { } else {
user = { user = {
name: 'Unassigned', name: s__('UsersSelect|Unassigned'),
username: '', username: '',
avatar: '', avatar: '',
}; };
tooltipTitle = __('Assignee'); tooltipTitle = s__('UsersSelect|Assignee');
} }
$value.html(assigneeTemplate(user)); $value.html(assigneeTemplate(user));
$collapsedSidebar.attr('title', tooltipTitle).tooltip('_fixTitle'); $collapsedSidebar.attr('title', tooltipTitle).tooltip('_fixTitle');
@ -233,7 +239,11 @@ function UsersSelect(currentUser, els, options = {}) {
'<% if( avatar ) { %> <a class="author-link" href="/<%- username %>"> <img width="24" class="avatar avatar-inline s24" alt="" src="<%- avatar %>"> </a> <% } else { %> <i class="fa fa-user"></i> <% } %>', '<% if( avatar ) { %> <a class="author-link" href="/<%- username %>"> <img width="24" class="avatar avatar-inline s24" alt="" src="<%- avatar %>"> </a> <% } else { %> <i class="fa fa-user"></i> <% } %>',
); );
assigneeTemplate = _.template( assigneeTemplate = _.template(
'<% if (username) { %> <a class="author-link bold" href="/<%- username %>"> <% if( avatar ) { %> <img width="32" class="avatar avatar-inline s32" alt="" src="<%- avatar %>"> <% } %> <span class="author"><%- name %></span> <span class="username"> @<%- username %> </span> </a> <% } else { %> <span class="no-value assign-yourself"> No assignee - <a href="#" class="js-assign-yourself"> assign yourself </a> </span> <% } %>', `<% if (username) { %> <a class="author-link bold" href="/<%- username %>"> <% if( avatar ) { %> <img width="32" class="avatar avatar-inline s32" alt="" src="<%- avatar %>"> <% } %> <span class="author"><%- name %></span> <span class="username"> @<%- username %> </span> </a> <% } else { %> <span class="no-value assign-yourself">
${sprintf(s__('UsersSelect|No assignee - %{openingTag} assign yourself %{closingTag}'), {
openingTag: '<a href="#" class="js-assign-yourself">',
closingTag: '</a>',
})}</span> <% } %>`,
); );
return $dropdown.glDropdown({ return $dropdown.glDropdown({
showMenuAbove: showMenuAbove, showMenuAbove: showMenuAbove,
@ -302,7 +312,7 @@ function UsersSelect(currentUser, els, options = {}) {
showDivider += 1; showDivider += 1;
users.unshift({ users.unshift({
beforeDivider: true, beforeDivider: true,
name: 'Unassigned', name: s__('UsersSelect|Unassigned'),
id: 0, id: 0,
}); });
} }
@ -310,7 +320,7 @@ function UsersSelect(currentUser, els, options = {}) {
showDivider += 1; showDivider += 1;
name = showAnyUser; name = showAnyUser;
if (name === true) { if (name === true) {
name = 'Any User'; name = s__('UsersSelect|Any User');
} }
anyUser = { anyUser = {
beforeDivider: true, beforeDivider: true,
@ -596,7 +606,7 @@ function UsersSelect(currentUser, els, options = {}) {
showEmailUser = $(select).data('emailUser'); showEmailUser = $(select).data('emailUser');
firstUser = $(select).data('firstUser'); firstUser = $(select).data('firstUser');
return $(select).select2({ return $(select).select2({
placeholder: 'Search for a user', placeholder: __('Search for a user'),
multiple: $(select).hasClass('multiselect'), multiple: $(select).hasClass('multiselect'),
minimumInputLength: 0, minimumInputLength: 0,
query: function(query) { query: function(query) {
@ -621,7 +631,7 @@ function UsersSelect(currentUser, els, options = {}) {
} }
if (showNullUser) { if (showNullUser) {
nullUser = { nullUser = {
name: 'Unassigned', name: s__('UsersSelect|Unassigned'),
id: 0, id: 0,
}; };
data.results.unshift(nullUser); data.results.unshift(nullUser);
@ -629,7 +639,7 @@ function UsersSelect(currentUser, els, options = {}) {
if (showAnyUser) { if (showAnyUser) {
name = showAnyUser; name = showAnyUser;
if (name === true) { if (name === true) {
name = 'Any User'; name = s__('UsersSelect|Any User');
} }
anyUser = { anyUser = {
name: name, name: name,
@ -645,7 +655,7 @@ function UsersSelect(currentUser, els, options = {}) {
) { ) {
var trimmed = query.term.trim(); var trimmed = query.term.trim();
emailUser = { emailUser = {
name: 'Invite "' + trimmed + '" by email', name: sprintf(__('Invite "%{trimmed}" by email'), { trimmed }),
username: trimmed, username: trimmed,
id: trimmed, id: trimmed,
invite: true, invite: true,
@ -688,7 +698,7 @@ UsersSelect.prototype.initSelection = function(element, callback) {
id = $(element).val(); id = $(element).val();
if (id === '0') { if (id === '0') {
nullUser = { nullUser = {
name: 'Unassigned', name: s__('UsersSelect|Unassigned'),
}; };
return callback(nullUser); return callback(nullUser);
} else if (id !== '') { } else if (id !== '') {

View file

@ -5249,6 +5249,9 @@ msgstr ""
msgid "Invite" msgid "Invite"
msgstr "" msgstr ""
msgid "Invite \"%{trimmed}\" by email"
msgstr ""
msgid "Invite group" msgid "Invite group"
msgstr "" msgstr ""
@ -8429,6 +8432,9 @@ msgstr ""
msgid "Search for a group" msgid "Search for a group"
msgstr "" msgstr ""
msgid "Search for a user"
msgstr ""
msgid "Search for projects, issues, etc." msgid "Search for projects, issues, etc."
msgstr "" msgstr ""
@ -8923,6 +8929,9 @@ msgstr ""
msgid "Something went wrong. Please try again." msgid "Something went wrong. Please try again."
msgstr "" msgstr ""
msgid "Something went wrong. Try again later."
msgstr ""
msgid "Sorry, no projects matched your search" msgid "Sorry, no projects matched your search"
msgstr "" msgstr ""
@ -10726,6 +10735,21 @@ msgstr ""
msgid "Users were successfully added." msgid "Users were successfully added."
msgstr "" msgstr ""
msgid "UsersSelect|%{name} + %{length} more"
msgstr ""
msgid "UsersSelect|Any User"
msgstr ""
msgid "UsersSelect|Assignee"
msgstr ""
msgid "UsersSelect|No assignee - %{openingTag} assign yourself %{closingTag}"
msgstr ""
msgid "UsersSelect|Unassigned"
msgstr ""
msgid "Using required encryption strategy when encrypted field is missing!" msgid "Using required encryption strategy when encrypted field is missing!"
msgstr "" msgstr ""