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 #31680 from hfiguiere/bug1155099-fm-mhz-l10n
Browse files Browse the repository at this point in the history
Bug 1155099 - Make 'MHz' localizable. r=justindarc
  • Loading branch information
hfiguiere committed Sep 4, 2015
2 parents 1dfcae1 + 13e3d0b commit 4bdc89c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
33 changes: 27 additions & 6 deletions apps/fm/js/fm.js
Expand Up @@ -158,6 +158,9 @@ var mozFMRadio = navigator.mozFM || navigator.mozFMRadio || {
aGlobal.SpeakerManager = SpeakerManager;
})(window);

// the mhzString that will be localized.
var mhzString = 'MHz-NOTLOCALIZED';

var enabling = false;
function updatePowerUI() {
var enabled = mozFMRadio.enabled;
Expand Down Expand Up @@ -619,12 +622,16 @@ var favoritesList = {
elem.id = this._getUIElemId(item);
elem.className = 'fav-list-item';
elem.setAttribute('role', 'option');
var html = '';
html += '<div class="fav-list-frequency">';
html += item.frequency.toFixed(1);
html += '</div>';
html += '<div class="fav-list-remove-button"></div>';
elem.innerHTML = html;

var subElem = document.createElement('div');
subElem.className = 'fav-list-frequency';
subElem.textContent = item.frequency.toFixed(1);
subElem.dataset.unit = mhzString;
elem.appendChild(subElem);

subElem = document.createElement('div');
subElem.className = 'fav-list-remove-button';
elem.appendChild(subElem);

// keep list ascending sorted
if (container.childNodes.length === 0) {
Expand Down Expand Up @@ -876,6 +883,20 @@ function init() {
});
}

document.addEventListener('DOMLocalized', function() {
// localize MHz
document.l10n.format('mhz').then(str => {
mhzString = str.value;
$('frequency').dataset.unit = mhzString;

var nodes = document.querySelectorAll(
'#fav-list-container div.fav-list-frequency');
for(var i = 0; i < nodes.length; i++) {
nodes[i].dataset.unit = mhzString;
}
});
});

document.addEventListener('DOMLocalized', function onDOMLocalized(e) {
// PERFORMANCE MARKER (1): navigationLoaded
// Designates that the app's *core* chrome or navigation interface
Expand Down
2 changes: 2 additions & 0 deletions apps/fm/locales/fm.en-US.properties
Expand Up @@ -3,6 +3,8 @@ noAntennaMsg = FM Radio requires a plugged in headset to receive radio sig
airplaneModeHeader = Airplane mode is on
airplaneModeMsg = Turn off Airplane mode to use FM Radio.

mhz = MHz

# The following strings are spoken by screen readers and not shown on the
# screen.
speaker-switch.ariaLabel = Speaker
Expand Down
4 changes: 2 additions & 2 deletions apps/fm/style/fm.css
Expand Up @@ -105,7 +105,7 @@ a:active {
}

#frequency::after {
content: "MHz";
content: attr(data-unit);
font-size: 1.5rem;
padding-left: 0.3rem;
}
Expand Down Expand Up @@ -313,7 +313,7 @@ div#fav-list-container div.fav-list-frequency {
}

div#fav-list-container div.fav-list-frequency::after {
content: "MHz";
content: attr(data-unit);
font-size: 1.5rem;
position: absolute;
padding: .6rem .2rem 0 1rem;
Expand Down

0 comments on commit 4bdc89c

Please sign in to comment.