MCPcopy Index your code
hub / github.com/codecombat/codecombat / translate

Function translate

compile-static-templates.js:65–89  ·  view source on GitHub ↗
(key, chinaInfra)

Source from the content-addressed store, hash-verified

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]; }

Callers 1

compileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected