mirror of
https://gitlab.com/timvisee/send.git
synced 2024-11-10 05:02:45 +01:00
localize file sizes
This commit is contained in:
parent
163899467d
commit
adf9c7b96f
@ -17,6 +17,7 @@ import './main.css';
|
||||
import User from './user';
|
||||
import { getTranslator } from './locale';
|
||||
import Archive from './archive';
|
||||
import { setTranslate } from './utils';
|
||||
|
||||
if (navigator.doNotTrack !== '1' && window.RAVEN_CONFIG) {
|
||||
Raven.config(window.SENTRY_ID, window.RAVEN_CONFIG).install();
|
||||
@ -40,6 +41,7 @@ if (process.env.NODE_ENV === 'production') {
|
||||
}
|
||||
|
||||
const translate = await getTranslator(LOCALE);
|
||||
setTranslate(translate);
|
||||
window.initialState = {
|
||||
LIMITS,
|
||||
DEFAULTS,
|
||||
|
17
app/utils.js
17
app/utils.js
@ -56,7 +56,7 @@ const LOCALIZE_NUMBERS = !!(
|
||||
typeof navigator === 'object'
|
||||
);
|
||||
|
||||
const UNITS = ['B', 'kB', 'MB', 'GB'];
|
||||
const UNITS = ['bytes', 'kb', 'mb', 'gb'];
|
||||
function bytes(num) {
|
||||
if (num < 1) {
|
||||
return '0B';
|
||||
@ -76,7 +76,10 @@ function bytes(num) {
|
||||
// fall through
|
||||
}
|
||||
}
|
||||
return `${nStr}${UNITS[exponent]}`;
|
||||
return translate('fileSize', {
|
||||
num: nStr,
|
||||
units: translate(UNITS[exponent])
|
||||
});
|
||||
}
|
||||
|
||||
function percent(ratio) {
|
||||
@ -256,6 +259,13 @@ function encryptedSize(size, rs = ECE_RECORD_SIZE, tagLength = TAG_LENGTH) {
|
||||
return 21 + size + chunk_meta * Math.ceil(size / (rs - chunk_meta));
|
||||
}
|
||||
|
||||
let translate = function() {
|
||||
throw new Error('uninitialized translate function. call setTranslate first');
|
||||
};
|
||||
function setTranslate(t) {
|
||||
translate = t;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
fadeOut,
|
||||
delay,
|
||||
@ -275,5 +285,6 @@ module.exports = {
|
||||
secondsToL10nId,
|
||||
timeLeft,
|
||||
platform,
|
||||
encryptedSize
|
||||
encryptedSize,
|
||||
setTranslate
|
||||
};
|
||||
|
@ -73,7 +73,17 @@ fileCount = { $num ->
|
||||
[one] 1 file
|
||||
*[other] { $num } files
|
||||
}
|
||||
# size is a localized number followed by a unit of bytes, ex. 2.5GB
|
||||
# byte abbreviation
|
||||
bytes = B
|
||||
# kibibyte abbreviation
|
||||
kb = KB
|
||||
# mebibyte abbreviation
|
||||
mb = MB
|
||||
# gibibyte abbreviation
|
||||
gb = GB
|
||||
# localized number and byte abbreviation. example "2.5MB"
|
||||
fileSize = { $num }{ $units }
|
||||
# $size is the size of the file, displayed using the fileSize message as format (e.g. "2.5MB")
|
||||
totalSize = Total size: { $size }
|
||||
# the next line after the colon contains a file name
|
||||
copyLinkDescription = Copy the link to share your file:
|
||||
@ -103,15 +113,15 @@ uploadButton = Upload
|
||||
# the first part of the string 'Drag and drop files or click to send up to 1GB'
|
||||
dragAndDropFiles = Drag and drop files
|
||||
# the second part of the string 'Drag and drop files or click to send up to 1GB'
|
||||
# size is a localized number followed by a unit of bytes, ex. 2.5GB
|
||||
# $size is the size of the file, displayed using the fileSize message as format (e.g. "2.5MB")
|
||||
orClickWithSize = or click to send up to { $size }
|
||||
addPassword = Protect with password
|
||||
emailPlaceholder = Enter your email
|
||||
# size is a localized number followed by a unit of bytes, ex. 2.5GB
|
||||
# $size is the size of the file, displayed using the fileSize message as format (e.g. "2.5MB")
|
||||
signInSizeBump = Sign in to send up to { $size }
|
||||
signInButton = Sign in/up
|
||||
accountBenefitTitle = Create a { -firefox } Account or sign in
|
||||
# size is a localized number followed by a unit of bytes, ex. 2.5GB
|
||||
# $size is the size of the file, displayed using the fileSize message as format (e.g. "2.5MB")
|
||||
accountBenefitLargeFiles = Share files up to { $size }
|
||||
accountBenefitDownloadCount = Share files with more people
|
||||
accountBenefitTimeLimit = { $count ->
|
||||
|
Loading…
Reference in New Issue
Block a user