From 6a9b6c22ef25bf867e1cddeb7981e19aade8ecec Mon Sep 17 00:00:00 2001 From: Brandon Labuschagne Date: Tue, 30 Apr 2019 17:21:39 +0000 Subject: [PATCH] Internationalisation of blob 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 --- .../javascripts/blob/balsamiq_viewer.js | 3 +- .../javascripts/blob/blob_file_dropzone.js | 5 ++-- app/assets/javascripts/blob/sketch/index.js | 5 ++-- .../template_selectors/dockerfile_selector.js | 3 +- app/assets/javascripts/blob/viewer/index.js | 14 +++++---- locale/gitlab.pot | 30 +++++++++++++++++++ 6 files changed, 49 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/blob/balsamiq_viewer.js b/app/assets/javascripts/blob/balsamiq_viewer.js index b88e69a07bf..2e537d8c000 100644 --- a/app/assets/javascripts/blob/balsamiq_viewer.js +++ b/app/assets/javascripts/blob/balsamiq_viewer.js @@ -1,8 +1,9 @@ import Flash from '../flash'; import BalsamiqViewer from './balsamiq/balsamiq_viewer'; +import { __ } from '~/locale'; function onError() { - const flash = new Flash('Balsamiq file could not be loaded.'); + const flash = new Flash(__('Balsamiq file could not be loaded.')); return flash; } diff --git a/app/assets/javascripts/blob/blob_file_dropzone.js b/app/assets/javascripts/blob/blob_file_dropzone.js index cd3251ad1ca..9010cd0c3c1 100644 --- a/app/assets/javascripts/blob/blob_file_dropzone.js +++ b/app/assets/javascripts/blob/blob_file_dropzone.js @@ -5,6 +5,7 @@ import Dropzone from 'dropzone'; import { visitUrl } from '../lib/utils/url_utility'; import { HIDDEN_CLASS } from '../lib/utils/constants'; import csrf from '../lib/utils/csrf'; +import { sprintf, __ } from '~/locale'; Dropzone.autoDiscover = false; @@ -73,7 +74,7 @@ export default class BlobFileDropzone { .html(errorMessage) .text(); $('.dropzone-alerts') - .html(`Error uploading file: "${stripped}"`) + .html(sprintf(__('Error uploading file: %{stripped}'), { stripped })) .show(); this.removeFile(file); }, @@ -84,7 +85,7 @@ export default class BlobFileDropzone { e.stopPropagation(); if (dropzone[0].dropzone.getQueuedFiles().length === 0) { // eslint-disable-next-line no-alert - alert('Please select a file'); + alert(__('Please select a file')); return false; } toggleLoading(submitButton, submitButtonLoadingIcon, true); diff --git a/app/assets/javascripts/blob/sketch/index.js b/app/assets/javascripts/blob/sketch/index.js index 57c1baa9886..dbff03dc734 100644 --- a/app/assets/javascripts/blob/sketch/index.js +++ b/app/assets/javascripts/blob/sketch/index.js @@ -1,5 +1,6 @@ import JSZip from 'jszip'; import JSZipUtils from 'jszip-utils'; +import { __ } from '~/locale'; export default class SketchLoader { constructor(container) { @@ -56,10 +57,10 @@ export default class SketchLoader { const errorMsg = document.createElement('p'); errorMsg.className = 'prepend-top-default append-bottom-default text-center'; - errorMsg.textContent = ` + errorMsg.textContent = __(` Cannot show preview. For previews on sketch files, they must have the file format introduced by Sketch version 43 and above. - `; + `); this.container.appendChild(errorMsg); this.removeLoadingIcon(); diff --git a/app/assets/javascripts/blob/template_selectors/dockerfile_selector.js b/app/assets/javascripts/blob/template_selectors/dockerfile_selector.js index 4718b642617..659d57e6a6f 100644 --- a/app/assets/javascripts/blob/template_selectors/dockerfile_selector.js +++ b/app/assets/javascripts/blob/template_selectors/dockerfile_selector.js @@ -1,11 +1,12 @@ import FileTemplateSelector from '../file_template_selector'; +import { __ } from '~/locale'; export default class DockerfileSelector extends FileTemplateSelector { constructor({ mediator }) { super(mediator); this.config = { key: 'dockerfile', - name: 'Dockerfile', + name: __('Dockerfile'), pattern: /(Dockerfile)/, type: 'dockerfiles', dropdown: '.js-dockerfile-selector', diff --git a/app/assets/javascripts/blob/viewer/index.js b/app/assets/javascripts/blob/viewer/index.js index d0359fc5fe9..d246a1f6064 100644 --- a/app/assets/javascripts/blob/viewer/index.js +++ b/app/assets/javascripts/blob/viewer/index.js @@ -2,6 +2,7 @@ import $ from 'jquery'; import Flash from '../../flash'; import { handleLocationHash } from '../../lib/utils/common_utils'; import axios from '../../lib/utils/axios_utils'; +import { __ } from '~/locale'; export default class BlobViewer { constructor() { @@ -26,7 +27,7 @@ export default class BlobViewer { promise .then(module => module.default(viewer)) .catch(error => { - Flash('Error loading file viewer.'); + Flash(__('Error loading file viewer.')); throw error; }); @@ -106,16 +107,19 @@ export default class BlobViewer { if (!this.copySourceBtn) return; if (this.simpleViewer.getAttribute('data-loaded')) { - this.copySourceBtn.setAttribute('title', 'Copy source to clipboard'); + this.copySourceBtn.setAttribute('title', __('Copy source to clipboard')); this.copySourceBtn.classList.remove('disabled'); } else if (this.activeViewer === this.simpleViewer) { this.copySourceBtn.setAttribute( 'title', - 'Wait for the source to load to copy it to the clipboard', + __('Wait for the source to load to copy it to the clipboard'), ); this.copySourceBtn.classList.add('disabled'); } else { - this.copySourceBtn.setAttribute('title', 'Switch to the source to copy it to the clipboard'); + this.copySourceBtn.setAttribute( + 'title', + __('Switch to the source to copy it to the clipboard'), + ); this.copySourceBtn.classList.add('disabled'); } @@ -158,7 +162,7 @@ export default class BlobViewer { this.toggleCopyButtonState(); }) - .catch(() => new Flash('Error loading viewer')); + .catch(() => new Flash(__('Error loading viewer'))); } static loadViewer(viewerParam) { diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 3d56efa9834..7ce605af062 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -1296,6 +1296,9 @@ msgstr "" msgid "Badges|e.g. %{exampleUrl}" msgstr "" +msgid "Balsamiq file could not be loaded." +msgstr "" + msgid "BambooService|A continuous integration and build server" msgstr "" @@ -1614,6 +1617,9 @@ msgstr "" msgid "Cannot render the image. Maximum character count (%{charLimit}) has been exceeded." msgstr "" +msgid "Cannot show preview. For previews on sketch files, they must have the file format introduced by Sketch version 43 and above." +msgstr "" + msgid "Cannot skip two factor authentication setup" msgstr "" @@ -2714,6 +2720,9 @@ msgstr "" msgid "Copy secret to clipboard" msgstr "" +msgid "Copy source to clipboard" +msgstr "" + msgid "Copy to clipboard" msgstr "" @@ -3292,6 +3301,9 @@ msgstr "" msgid "Do you want to customize how Google Code email addresses and usernames are imported into GitLab?" msgstr "" +msgid "Dockerfile" +msgstr "" + msgid "Domain" msgstr "" @@ -3709,6 +3721,9 @@ msgstr "" msgid "Error loading branches." msgstr "" +msgid "Error loading file viewer." +msgstr "" + msgid "Error loading last commit." msgstr "" @@ -3727,6 +3742,9 @@ msgstr "" msgid "Error loading template." msgstr "" +msgid "Error loading viewer" +msgstr "" + msgid "Error occurred when toggling the notification subscription" msgstr "" @@ -3760,6 +3778,9 @@ msgstr "" msgid "Error uploading file" msgstr "" +msgid "Error uploading file: %{stripped}" +msgstr "" + msgid "Error while loading the merge request. Please try again." msgstr "" @@ -6658,6 +6679,9 @@ msgstr "" msgid "Please note that this application is not provided by GitLab and you should verify its authenticity before allowing access." msgstr "" +msgid "Please select a file" +msgstr "" + msgid "Please select a group." msgstr "" @@ -8725,6 +8749,9 @@ msgstr "" msgid "Switch to GitLab Next" msgstr "" +msgid "Switch to the source to copy it to the clipboard" +msgstr "" + msgid "System Hooks" msgstr "" @@ -10240,6 +10267,9 @@ msgstr "" msgid "VisibilityLevel|Unknown" msgstr "" +msgid "Wait for the source to load to copy it to the clipboard" +msgstr "" + msgid "Want to see the data? Please ask an administrator for access." msgstr ""