Skip to content
This repository has been archived by the owner on May 22, 2021. It is now read-only.

Localization #245

Merged
merged 6 commits into from Jul 19, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 9 additions & 5 deletions frontend/src/download.js
Expand Up @@ -47,8 +47,11 @@ $(document).ready(function() {
//on complete
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disclaimer: I have zero idea what I'm talking about, but I'd assume that the filesizes may need to be localized as well. For example, up on lines 34-45 above where we say "23KB", or "199MB", or "1.5GB".

if (percent === 1) {
fileReceiver.removeAllListeners('progress');
notify('Your download has finished.');
$('.title').html('Download Complete');
document.l10n.formatValues('downloadNotification', 'downloadFinish')
.then(translated => {
notify(translated[0]);
$('.title').html(translated[1]);
})
}
});

Expand All @@ -73,9 +76,10 @@ $(document).ready(function() {
fileReceiver
.download()
.catch(() => {
$('.title').text(
'This link has expired or never existed in the first place.'
);
document.l10n.formatValue('expiredPageHeader')
.then(translated => {
$('.title').text(translated);
})
$('#download-btn').hide();
$('#expired-img').show();
console.log('The file has expired, or has already been deleted.');
Expand Down
59 changes: 45 additions & 14 deletions frontend/src/upload.js
Expand Up @@ -17,7 +17,7 @@ $(document).ready(function() {
const $copyBtn = $('#copy-btn');
$copyBtn.attr('disabled', false);
$('#link').attr('disabled', false);
$copyBtn.html('Copy to Clipboard');
$copyBtn.attr('data-l10n-id', 'copyUrlFormButton');

$('#upload-progress').hide();
$('#share-link').hide();
Expand Down Expand Up @@ -51,7 +51,7 @@ $(document).ready(function() {
window.setTimeout(() => {
$copyBtn.attr('disabled', false);
$('#link').attr('disabled', false);
$copyBtn.html('Copy to Clipboard');
$copyBtn.attr('data-l10n-id', 'copyUrlFormButton');
}, 3000);
});

Expand All @@ -75,7 +75,7 @@ $(document).ready(function() {
$('#upload-error').hide();
$copyBtn.attr('disabled', false);
$('#link').attr('disabled', false);
$copyBtn.html('Copy to Clipboard');
$copyBtn.attr('data-l10n-id', 'copyUrlFormButton');
$('.upload-window').removeClass('ondrag');
$('#page-one').show();
});
Expand Down Expand Up @@ -164,7 +164,7 @@ $(document).ready(function() {
expiry: expiration
};
localStorage.setItem(info.fileId, JSON.stringify(fileData));
$('#upload-filename').html('Ready to Send');
$('#upload-filename').attr('data-l10n-id', 'uploadSuccessConfirmHeader');
t = window.setTimeout(() => {
$('#page-one').hide();
$('#upload-progress').hide();
Expand All @@ -173,7 +173,9 @@ $(document).ready(function() {
}, 2000);

populateFileList(JSON.stringify(fileData));
notify('Your upload has finished.');
document.l10n.formatValue('notifyUploadDone').then(str => {
notify(str);
});
})
.catch(err => {
Raven.captureException(err);
Expand Down Expand Up @@ -225,17 +227,30 @@ $(document).ready(function() {

const url = file.url.trim() + `#${file.secretKey}`.trim();
$('#link').attr('value', url);
$('#copy-text').html(
'Copy and share the link to send your file: ' + file.name
$('#copy-text').attr(
'data-l10n-args',
'{"filename": "' + file.name + '"}'
);
$('#copy-text').attr(
'data-l10n-id',
'copyUrlFormLabelWithName'
);
$popupText.attr('tabindex', '-1');

name.appendChild(cellText);

// create delete button
del.innerHTML = '<span class="icon-cancel-1" title="Delete"></span>';

link.innerHTML = '<span class="icon-docs" title="Copy URL"></span>';
const delSpan = document.createElement('span');
$(delSpan).addClass('icon-cancel-1');
$(delSpan).attr('data-l10n-id', 'deleteButtonHover');
del.appendChild(delSpan);

const linkSpan = document.createElement('span');
$(linkSpan).addClass('icon-docs');
$(linkSpan).attr('data-l10n-id', 'copyUrlHover');
link.appendChild(linkSpan);

link.style.color = '#0A8DFF';
//copy link to clipboard when icon clicked
$(link).click(function() {
Expand All @@ -245,9 +260,15 @@ $(document).ready(function() {
aux.select();
document.execCommand('copy');
document.body.removeChild(aux);
link.innerHTML = 'Copied!';
document.l10n.formatValue('copiedUrl')
.then(translated => {
link.innerHTML = translated;
})
window.setTimeout(() => {
link.innerHTML = '<span class="icon-docs" title="Copy URL"></span>';
const linkSpan = document.createElement('span');
$(linkSpan).addClass('icon-docs');
$(linkSpan).attr('data-l10n-id', 'copyUrlHover');
$(link).html(linkSpan);
}, 500);
});

Expand Down Expand Up @@ -293,9 +314,19 @@ $(document).ready(function() {

// create popup
popupDiv.classList.add('popup');
$popupText.html(
'<span class="del-file">Delete</span><span class="nvm" > Nevermind</span>'
);
const popupDelSpan = document.createElement('span');
$(popupDelSpan).addClass('del-file');
$(popupDelSpan).attr('data-l10n-id', 'sentFilesTitle4');

const popupNvmSpan = document.createElement('span');
$(popupNvmSpan).addClass('nvm');
$(popupNvmSpan).attr('data-l10n-id', 'nevermindButton');

$popupText.html([
popupDelSpan,
'&nbsp;',
popupNvmSpan
]);

// delete file
$popupText.find('.del-file').click(e => {
Expand Down