Skip to content

Commit

Permalink
修复测试用例
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoEatle committed Aug 13, 2020
1 parent 6683d6e commit 4cd02ab
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/i18nc/test/output/file2i18nc.json
Expand Up @@ -3,7 +3,7 @@
"originalFileKeys": [],
"subScopeDatas": [
{
"code": "{\n\n\n\t/* eslint-disable */\n\tfunction I18N(msg, tpldata, subkey) {\n\t\tif (!msg) return msg === undefined || msg === null ? '' : '' + msg;\n\n\t\tvar self = I18N,\n\t\t\tdata = self.$ || (self.$ = {}),\n\t\t\ttranslateJSON,\n\t\t\treplace_index = 0,\n\t\t\toptions = {},\n\t\t\tlanIndexArr,\n\t\t\ti,\n\t\t\tlanIndex,\n\t\t\tmsgResult,\n\t\t\ttranslateValues;\n\n\t\tif (!tpldata || !tpldata.join) {\n\t\t\tsubkey = tpldata;\n\t\t\ttpldata = [];\n\t\t}\n\n\t\tif (subkey && typeof subkey == 'object') {\n\t\t\toptions = subkey;\n\t\t\tsubkey = options.subkey;\n\t\t}\n\n\t\tvar LAN = options.language || (function(cache) {\n\t\t\tif (!cache.global) {\n\t\t\t\tcache.global =\n\t\t\t\t\t(typeof window == 'object' && window) ||\n\t\t\t\t\t(typeof global == 'object' && global) ||\n\t\t\t\t\t{};\n\t\t\t}\n\t\n\t\t\treturn cache.global.__i18n_lan__;\n\t\t})(data);\n\n\t\tif (LAN && LAN.split) {\n\t\t\tif (self.L != LAN) {\n\t\t\t\tself.K = '*';\n\t\t\t\tself.V = 'Kf';\n\t\t\t\tself.D = {\n\t\t\t\t\t'*': {\n\t\t\t\t\t\t// '中文':\n\t\t\t\t\t\t// '中文词典':\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\ttranslateJSON = self.D;\n\n\t\t\t\tvar dblans = translateJSON.$ || [],\n\t\t\t\t\tdblansMap = {},\n\t\t\t\t\tlanKeys = LAN.split(',');\n\t\t\t\tlanIndexArr = self.M = [];\n\n\t\t\t\tfor (i = dblans.length; i--; ) dblansMap[dblans[i]] = i;\n\n\t\t\t\tfor (i = lanKeys.length; i--; ) {\n\t\t\t\t\tlanIndex = dblansMap[lanKeys[i]];\n\t\t\t\t\tif (lanIndex || lanIndex === 0) lanIndexArr.push(lanIndex);\n\t\t\t\t}\n\t\t\t\tself.L = LAN;\n\t\t\t}\n\n\t\t\tlanIndexArr = self.M;\n\t\t\ttranslateJSON = self.D;\n\t\t\tvar _getVaule = function(subkey) {\n\t\t\t\ttranslateValues =\n\t\t\t\t\ttranslateJSON[subkey] && translateJSON[subkey][msg];\n\t\t\t\tif (translateValues) {\n\t\t\t\t\tmsgResult = translateValues[lanIndex];\n\t\t\t\t\tif (typeof msgResult == 'number')\n\t\t\t\t\t\tmsgResult = translateValues[msgResult];\n\t\t\t\t}\n\t\t\t};\n\t\t\tfor (i = lanIndexArr.length; !msgResult && i--; ) {\n\t\t\t\tlanIndex = lanIndexArr[i];\n\t\t\t\tif (subkey) _getVaule(subkey);\n\t\t\t\tif (!msgResult) _getVaule('*');\n\t\t\t}\n\n\t\t\tif (msgResult) msg = msgResult;\n\t\t}\n\n\t\tmsg += '';\n\t\tif (!tpldata.length || msg.indexOf('%') == -1) return msg;\n\n\t\treturn msg\n\t\t\t.replace(/%\\{(\\d+)\\}/g, function(all, index) {\n\t\t\t\tvar newVal = tpldata[+index];\n\t\t\t\treturn newVal === undefined ? '' : newVal;\n\t\t\t})\n\t\t\t.replace(/%s|%p|%\\{.+?\\}/g, function() {\n\t\t\t\tvar newVal = tpldata[replace_index++];\n\t\t\t\treturn newVal === undefined ? '' : newVal;\n\t\t\t});\n\t}\n\t/* eslint-enable */\n\n\n\n\tvar val = I18N('中文');\n\tconsole.log(\"日志不翻译\");\n\ttalkme(I18N('中文词典'));\n}",
"code": "{\n\n\n\t/* eslint-disable */\n\tfunction I18N(msg, tpldata, subkey) {\n\t\tif (!msg) return msg === undefined || msg === null ? '' : '' + msg;\n\n\t\tvar self = I18N,\n\t\t\tdata = self.$ || (self.$ = {}),\n\t\t\ttranslateJSON,\n\t\t\treplace_index = 0,\n\t\t\toptions = {},\n\t\t\tlanIndexArr,\n\t\t\ti,\n\t\t\tlanIndex,\n\t\t\ttranslateMsg,\n\t\t\ttranslateValues;\n\n\t\tif (!tpldata || !tpldata.join) {\n\t\t\tsubkey = tpldata;\n\t\t\ttpldata = [];\n\t\t}\n\n\t\tif (subkey && typeof subkey == 'object') {\n\t\t\toptions = subkey;\n\t\t\tsubkey = options.subkey;\n\t\t}\n\n\t\tvar LAN = options.language || (function(cache) {\n\t\t\tif (!cache.global) {\n\t\t\t\tcache.global =\n\t\t\t\t\t(typeof window == 'object' && window) ||\n\t\t\t\t\t(typeof global == 'object' && global) ||\n\t\t\t\t\t{};\n\t\t\t}\n\t\n\t\t\treturn cache.global.__i18n_lan__;\n\t\t})(data);\n\n\t\tif (LAN && LAN.split) {\n\t\t\tif (self.L != LAN) {\n\t\t\t\tself.K = '*';\n\t\t\t\tself.V = 'Lf';\n\t\t\t\tself.D = {\n\t\t\t\t\t'*': {\n\t\t\t\t\t\t// '中文':\n\t\t\t\t\t\t// '中文词典':\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\ttranslateJSON = self.D;\n\n\t\t\t\tvar dblans = translateJSON.$ || [],\n\t\t\t\t\tdblansMap = {},\n\t\t\t\t\tlanKeys = LAN.split(',');\n\t\t\t\tlanIndexArr = self.M = [];\n\n\t\t\t\tfor (i = dblans.length; i--; ) dblansMap[dblans[i]] = i;\n\n\t\t\t\tfor (i = lanKeys.length; i--; ) {\n\t\t\t\t\tlanIndex = dblansMap[lanKeys[i]];\n\t\t\t\t\tif (lanIndex || lanIndex === 0) lanIndexArr.push(lanIndex);\n\t\t\t\t}\n\t\t\t\tself.L = LAN;\n\t\t\t}\n\n\t\t\tlanIndexArr = self.M;\n\t\t\ttranslateJSON = self.D;\n\t\t\tvar _getVaule = function(subkey) {\n\t\t\t\ttranslateValues =\n\t\t\t\t\ttranslateJSON[subkey] && translateJSON[subkey][msg];\n\t\t\t\tif (translateValues) {\n\t\t\t\t\ttranslateMsg = translateValues[lanIndex];\n\t\t\t\t\tif (typeof translateMsg == 'number')\n\t\t\t\t\t\ttranslateMsg = translateValues[translateMsg];\n\t\t\t\t}\n\t\t\t};\n\t\t\tfor (i = lanIndexArr.length; !translateMsg && i--; ) {\n\t\t\t\tlanIndex = lanIndexArr[i];\n\t\t\t\tif (subkey) _getVaule(subkey);\n\t\t\t\tif (!translateMsg) _getVaule('*');\n\t\t\t}\n\n\t\t\tif (translateMsg) {\n\t\t\t\tmsg = translateMsg;\n\t\t\t} else if (options.forceMatch) {\n\t\t\t\treturn '';\n\t\t\t}\n\t\t}\n\n\t\tmsg += '';\n\t\tif (!tpldata.length || msg.indexOf('%') == -1) return msg;\n\n\t\treturn msg\n\t\t\t.replace(/%\\{(\\d+)\\}/g, function(all, index) {\n\t\t\t\tvar newVal = tpldata[+index];\n\t\t\t\treturn newVal === undefined ? '' : newVal;\n\t\t\t})\n\t\t\t.replace(/%s|%p|%\\{.+?\\}/g, function() {\n\t\t\t\tvar newVal = tpldata[replace_index++];\n\t\t\t\treturn newVal === undefined ? '' : newVal;\n\t\t\t});\n\t}\n\t/* eslint-enable */\n\n\n\n\tvar val = I18N('中文');\n\tconsole.log(\"日志不翻译\");\n\ttalkme(I18N('中文词典'));\n}",
"currentFileKey": "*",
"originalFileKeys": [],
"subScopeDatas": [],
Expand Down
4 changes: 2 additions & 2 deletions packages/i18nc/test/test_getlans.js
Expand Up @@ -35,7 +35,7 @@ describe('#getlans', function() {

it('#filter', function() {
expect(
getlans.filter(['zh-hk', 'zh-tw', 'en-us'], ['zh-hk', 'en'])
).to.eql(['zh-hk', 'en-us']);
getlans.filter(['zh-cn', 'zh-tw', 'en-us'], ['zh', 'en', 'cht'])
).to.eql('zh');
});
});

0 comments on commit 4cd02ab

Please sign in to comment.