VulpesOS/gaia/apps/communications/contacts/test/unit/mock_l10n.js
OverSu b38dea0597 Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
2026-09-30 23:13:03 +02:00

61 lines
1.2 KiB
JavaScript
Executable file

'use strict';
/* exported MockMozL10n */
window.realL10n = window.navigator.mozL10n;
var MockMozL10n = window.navigator.mozL10n = {
realL10nCB: null,
language: {
code: 'en',
direction: 'ltr'
},
get: function get(key, params) {
var out = key;
if (params) {
if (key == 'itemWithLabel') {
out = params.label + ', ' + params.item;
} else {
Object.keys(params).forEach(function(id) {
out += params[id];
});
}
}
return out;
},
translate: function() {},
once: function(cb) {
this.realL10nCB = cb;
this.onceCb = cb;
cb();
},
ready: function(cb) {
this.readyCb = cb;
},
fireReady: function() {
if (!this.readyCb) {
return;
}
this.readyCb();
},
fireOnce: function() {
if (!this.onceCb) {
return;
}
this.onceCb();
},
setAttributes: function(element, id, args) {
element.setAttribute('data-l10n-id', id);
if (args) {
element.setAttribute('data-l10n-args', JSON.stringify(args));
}
},
getAttributes: function(element) {
return {
id: element.getAttribute('data-l10n-id'),
args: JSON.parse(element.getAttribute('data-l10n-args'))
};
},
};