MCPcopy Index your code
hub / github.com/prose/prose / t

Function t

locale.js:10–40  ·  view source on GitHub ↗
(s, o, loc)

Source from the content-addressed store, hash-verified

8};
9
10function t(s, o, loc) {
11 if (!arguments.length) return;
12 loc = loc || locale._current;
13
14 var path = s.split('.').reverse(),
15 rep = locale[loc];
16
17 while (rep !== undefined && path.length) rep = rep[path.pop()];
18
19 if (rep !== undefined) {
20 if (o) for (var k in o) rep = rep.replace('{' + k + '}', o[k]);
21 return rep;
22 } else {
23 function missing() {
24 var missing = 'Missing ' + loc + ' translation: ' + s;
25 if (typeof console !== "undefined") console.error(missing);
26 return missing;
27 }
28
29 if (loc !== 'en') {
30 missing();
31 return t(s, o, 'en');
32 }
33
34 if (o && 'default' in o) {
35 return o['default'];
36 }
37
38 return missing();
39 }
40}

Callers 15

util.jsFile · 0.85
router.jsFile · 0.85
boot.jsFile · 0.85
markdown.jsFile · 0.85
files.jsFile · 0.85
notification.jsFile · 0.85
documentation.jsFile · 0.85
nav.jsFile · 0.85
header.jsFile · 0.85
search.jsFile · 0.85
file.jsFile · 0.85
toolbar.jsFile · 0.85

Calls 1

missingFunction · 0.85

Tested by

no test coverage detected