(s, o, loc)
| 8 | }; |
| 9 | |
| 10 | function 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 | } |
no test coverage detected