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

Commit

Permalink
Merge pull request #11109 from TheoChevalier/Bug835611-localized-unit…
Browse files Browse the repository at this point in the history
…s-costcontrol

Bug 835611 - [l10n] Cost Control should use localized units r=salva
  • Loading branch information
rik committed Jul 24, 2013
2 parents edb1dea + b5d18e1 commit d1388ba
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
10 changes: 5 additions & 5 deletions apps/costcontrol/js/settings/limitdialog.js
Expand Up @@ -8,7 +8,7 @@ function dataLimitConfigurer(guiWidget, settings, viewManager) {
var dataLimitInput = dialog.querySelector('input');
var format = function ccal_formatterDataUnit(value) {
var unit = settings.option('dataLimitUnit');
return formatData([value, unit]);
return formatData([value, _(unit)]);
};

// Configure dialog
Expand Down Expand Up @@ -46,11 +46,11 @@ function dataLimitConfigurer(guiWidget, settings, viewManager) {
// Configure the swicth unit button
var currentUnit = settings.option('dataLimitUnit');
var switchUnitButton = dialog.querySelector('.switch-unit-button');
switchUnitButton.querySelector('span.tag').textContent = currentUnit;
switchUnitButton.querySelector('span.tag').textContent = _(currentUnit);
switchUnitButton.addEventListener('click',
function ccapp_switchUnit() {
currentUnit = (currentUnit === 'MB') ? 'GB' : 'MB';
switchUnitButton.querySelector('span.tag').textContent = currentUnit;
switchUnitButton.querySelector('span.tag').textContent = _(currentUnit);
}
);

Expand Down Expand Up @@ -89,7 +89,7 @@ function dataLimitConfigurer(guiWidget, settings, viewManager) {
}

// Set dialog
switchUnitButton.querySelector('span.tag').textContent = value;
switchUnitButton.querySelector('span.tag').textContent = _(value);

var tagSpan = guiWidget.querySelector('.tag');
tagSpan.textContent = format(dataLimitInput.value);
Expand All @@ -104,7 +104,7 @@ function dataLimitConfigurer(guiWidget, settings, viewManager) {
dataLimitInput.setSelectionRange(dataLimitInput.value.length,
dataLimitInput.value.length);
oldUnitValue = settings.option('dataLimitUnit');
switchUnitButton.querySelector('span.tag').textContent = oldUnitValue;
switchUnitButton.querySelector('span.tag').textContent = _(oldUnitValue);
});

}
16 changes: 8 additions & 8 deletions apps/costcontrol/js/utils/formatting.js
Expand Up @@ -23,18 +23,18 @@ function formatData(dataArray) {
function roundData(value, positions) {
positions = (typeof positions === 'undefined') ? 2 : positions;
if (value < 1000) {
return [value.toFixed(positions), 'B'];
return [value.toFixed(positions), _('B')];
}

if (value < 1000000) {
return [(value / 1000).toFixed(positions), 'KB'];
return [(value / 1000).toFixed(positions), _('KB')];
}

if (value < 1000000000) {
return [(value / 1000000).toFixed(positions), 'MB'];
return [(value / 1000000).toFixed(positions), _('MB')];
}

return [(value / 1000000000).toFixed(positions), 'GB'];
return [(value / 1000000000).toFixed(positions), _('GB')];
}

function getPositions(value) {
Expand All @@ -53,21 +53,21 @@ function getPositions(value) {
function smartRound(value) {
var positions;
if (value < 1000) {
return [value.toFixed(getPositions(value)), 'B'];
return [value.toFixed(getPositions(value)), _('B')];
}

if (value < 1000000) {
var kbytes = value / 1000;
return [kbytes.toFixed(getPositions(kbytes)), 'KB'];
return [kbytes.toFixed(getPositions(kbytes)), _('KB')];
}

if (value < 1000000000) {
var mbytes = value / 1000000;
return [mbytes.toFixed(getPositions(mbytes)), 'MB'];
return [mbytes.toFixed(getPositions(mbytes)), _('MB')];
}

var gbytes = value / 1000000000;
return [gbytes.toFixed(getPositions(gbytes)), 'GB'];
return [gbytes.toFixed(getPositions(gbytes)), _('GB')];
}

// Return a padded data value in MG/GB
Expand Down
6 changes: 6 additions & 0 deletions apps/costcontrol/locales/costcontrol.en-US.properties
Expand Up @@ -202,3 +202,9 @@ em-month-11 = DEV

# Specif format for CC, string in format Today|Yesterday|<WeekDay>, hh:mm
day-hour-format = {{day}}, {{time}}

# Localized units
B = B
KB = KB
MB = MB
GB = GB
6 changes: 6 additions & 0 deletions apps/costcontrol/locales/costcontrol.fr.properties
Expand Up @@ -184,3 +184,9 @@ phone = Téléphone
chart-date-format = %e %b
# Specif format for CC, string in format Today|Yesterday|<WeekDay>, hh:mm
day-hour-format = {{day}}, {{time}}

# Localized units
B = o
KB = Ko
MB = Mo
GB = Go

0 comments on commit d1388ba

Please sign in to comment.