MCPcopy
hub / github.com/52cik/github-hans / transPage

Function transPage

main.js:188–209  ·  view source on GitHub ↗

* 翻译页面内容 * * @param {string} page 页面 * @param {string} key 待翻译内容 * * @returns {string|boolean}

(page, key)

Source from the content-addressed store, hash-verified

186 * @returns {string|boolean}
187 */
188 function transPage(page, key) {
189 var str; // 翻译结果
190 var res; // 正则数组
191
192 // 静态翻译
193 str = I18N['zh'][page]['static'][key];
194 if (str) {
195 return str;
196 }
197
198 // 正则翻译
199 if (res = I18N['zh'][page]['regexp']) {
200 for (var i = 0, len = res.length; i < len; i++) {
201 str = key.replace(res[i][0], res[i][1]);
202 if (str !== key) {
203 return str;
204 }
205 }
206 }
207
208 return false; // 没有翻译条目
209 }
210
211
212 /**

Callers 1

translateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected