forked from mozilla-b2g/gaia
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlazy_l10n.js
More file actions
48 lines (38 loc) · 1.17 KB
/
Copy pathlazy_l10n.js
File metadata and controls
48 lines (38 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* globals LazyLoader*/
'use strict';
/**
* This provides a simple function call to delay localization load
* To use, simply wrap required localizable content with:
* LazyL10n.get(callback)
*/
(function() {
var loader = LazyLoader;
window.LazyL10n = {
_baseLoaded: false,
_ready: false,
get: function ll10n_get(callback) {
if (this._ready) {
callback(navigator.mozL10n.get);
return;
}
var loadDateAndFinalize = this._loadDateAndFinalize.bind(this, callback);
if (this._baseLoaded) {
navigator.mozL10n.once(loadDateAndFinalize);
return;
}
// Add the l10n JS files to the DOM and wait for them to load.
loader.load(['/shared/js/l10n.js'], function baseLoaded() {
this._baseLoaded = true;
navigator.mozL10n.once(loadDateAndFinalize);
}.bind(this));
},
_loadDateAndFinalize: function ll10n_loadDateAndFinalize(callback) {
loader.load('/shared/js/l10n_date.js',
this._finalize.bind(this, callback));
},
_finalize: function ll10n_finalize(callback) {
this._ready = true;
callback(navigator.mozL10n.get);
}
};
}());