| 63 | }); |
| 64 | |
| 65 | const translate = function(key, chinaInfra) { |
| 66 | let type = 'text'; |
| 67 | |
| 68 | const html = /^\[html\]/.test(key); |
| 69 | if (html) { key = key.substring(6); } |
| 70 | if (html) { type = 'html'; } |
| 71 | |
| 72 | const content = /^\[content\]/.test(key); |
| 73 | if (content) { key = key.substring(9); } |
| 74 | if (content) { type = 'content'; } |
| 75 | |
| 76 | let t = chinaInfra ? zh.translation : en.translation; |
| 77 | //TODO: Replace with _.property when we get modern lodash |
| 78 | const translationPath = key.split(/[.]/); |
| 79 | while (translationPath.length > 0) { |
| 80 | var k = translationPath.shift(); |
| 81 | t = t[k]; |
| 82 | if (t == null) { return key; } |
| 83 | } |
| 84 | |
| 85 | return out = { |
| 86 | text: t, |
| 87 | type |
| 88 | }; |
| 89 | }; |
| 90 | |
| 91 | const i18n = function(k,v) { |
| 92 | if (Array.from(k).includes('i18n')) { return k.i18n.en[a]; } |