Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
0be4f4ec
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0be4f4ec
编写于
1月 22, 2018
作者:
M
Martin Aeschlimann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[i18n] push compiles js file
上级
2d454455
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
38 addition
and
3 deletion
+38
-3
build/lib/i18n.js
build/lib/i18n.js
+38
-3
未找到文件。
build/lib/i18n.js
浏览文件 @
0be4f4ec
...
@@ -14,6 +14,7 @@ var glob = require("glob");
...
@@ -14,6 +14,7 @@ var glob = require("glob");
var
https
=
require
(
"
https
"
);
var
https
=
require
(
"
https
"
);
var
util
=
require
(
'
gulp-util
'
);
var
util
=
require
(
'
gulp-util
'
);
var
iconv
=
require
(
'
iconv-lite
'
);
var
iconv
=
require
(
'
iconv-lite
'
);
var
NUMBER_OF_CONCURRENT_DOWNLOADS
=
1
;
function
log
(
message
)
{
function
log
(
message
)
{
var
rest
=
[];
var
rest
=
[];
for
(
var
_i
=
1
;
_i
<
arguments
.
length
;
_i
++
)
{
for
(
var
_i
=
1
;
_i
<
arguments
.
length
;
_i
++
)
{
...
@@ -207,6 +208,36 @@ var XLF = /** @class */ (function () {
...
@@ -207,6 +208,36 @@ var XLF = /** @class */ (function () {
return
XLF
;
return
XLF
;
}());
}());
exports
.
XLF
=
XLF
;
exports
.
XLF
=
XLF
;
var
Limiter
=
/** @class */
(
function
()
{
function
Limiter
(
maxDegreeOfParalellism
)
{
this
.
maxDegreeOfParalellism
=
maxDegreeOfParalellism
;
this
.
outstandingPromises
=
[];
this
.
runningPromises
=
0
;
}
Limiter
.
prototype
.
queue
=
function
(
factory
)
{
var
_this
=
this
;
return
new
Promise
(
function
(
c
,
e
)
{
_this
.
outstandingPromises
.
push
({
factory
:
factory
,
c
:
c
,
e
:
e
});
_this
.
consume
();
});
};
Limiter
.
prototype
.
consume
=
function
()
{
var
_this
=
this
;
while
(
this
.
outstandingPromises
.
length
&&
this
.
runningPromises
<
this
.
maxDegreeOfParalellism
)
{
var
iLimitedTask
=
this
.
outstandingPromises
.
shift
();
this
.
runningPromises
++
;
var
promise
=
iLimitedTask
.
factory
();
promise
.
then
(
iLimitedTask
.
c
).
catch
(
iLimitedTask
.
e
);
promise
.
then
(
function
()
{
return
_this
.
consumed
();
}).
catch
(
function
()
{
return
_this
.
consumed
();
});
}
};
Limiter
.
prototype
.
consumed
=
function
()
{
this
.
runningPromises
--
;
this
.
consume
();
};
return
Limiter
;
}());
exports
.
Limiter
=
Limiter
;
var
iso639_3_to_2
=
{
var
iso639_3_to_2
=
{
'
chs
'
:
'
zh-cn
'
,
'
chs
'
:
'
zh-cn
'
,
'
cht
'
:
'
zh-tw
'
,
'
cht
'
:
'
zh-tw
'
,
...
@@ -826,8 +857,9 @@ function pullXlfFiles(projectName, apiHostname, username, password, languages, r
...
@@ -826,8 +857,9 @@ function pullXlfFiles(projectName, apiHostname, username, password, languages, r
});
});
}
}
exports
.
pullXlfFiles
=
pullXlfFiles
;
exports
.
pullXlfFiles
=
pullXlfFiles
;
var
limiter
=
new
Limiter
(
NUMBER_OF_CONCURRENT_DOWNLOADS
);
function
retrieveResource
(
language
,
resource
,
apiHostname
,
credentials
)
{
function
retrieveResource
(
language
,
resource
,
apiHostname
,
credentials
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
return
limiter
.
queue
(
function
()
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
var
slug
=
resource
.
name
.
replace
(
/
\/
/g
,
'
_
'
);
var
slug
=
resource
.
name
.
replace
(
/
\/
/g
,
'
_
'
);
var
project
=
resource
.
project
;
var
project
=
resource
.
project
;
var
iso639
=
language
.
toLowerCase
();
var
iso639
=
language
.
toLowerCase
();
...
@@ -835,6 +867,7 @@ function retrieveResource(language, resource, apiHostname, credentials) {
...
@@ -835,6 +867,7 @@ function retrieveResource(language, resource, apiHostname, credentials) {
hostname
:
apiHostname
,
hostname
:
apiHostname
,
path
:
"
/api/2/project/
"
+
project
+
"
/resource/
"
+
slug
+
"
/translation/
"
+
iso639
+
"
?file&mode=onlyreviewed
"
,
path
:
"
/api/2/project/
"
+
project
+
"
/resource/
"
+
slug
+
"
/translation/
"
+
iso639
+
"
?file&mode=onlyreviewed
"
,
auth
:
credentials
,
auth
:
credentials
,
port
:
443
,
method
:
'
GET
'
method
:
'
GET
'
};
};
var
request
=
https
.
request
(
options
,
function
(
res
)
{
var
request
=
https
.
request
(
options
,
function
(
res
)
{
...
@@ -842,16 +875,18 @@ function retrieveResource(language, resource, apiHostname, credentials) {
...
@@ -842,16 +875,18 @@ function retrieveResource(language, resource, apiHostname, credentials) {
res
.
on
(
'
data
'
,
function
(
chunk
)
{
return
xlfBuffer
.
push
(
chunk
);
});
res
.
on
(
'
data
'
,
function
(
chunk
)
{
return
xlfBuffer
.
push
(
chunk
);
});
res
.
on
(
'
end
'
,
function
()
{
res
.
on
(
'
end
'
,
function
()
{
if
(
res
.
statusCode
===
200
)
{
if
(
res
.
statusCode
===
200
)
{
console
.
log
(
'
success:
'
+
options
.
path
);
resolve
(
new
File
({
contents
:
Buffer
.
concat
(
xlfBuffer
),
path
:
project
+
"
/
"
+
iso639_2_to_3
[
language
]
+
"
/
"
+
slug
+
"
.xlf
"
}));
resolve
(
new
File
({
contents
:
Buffer
.
concat
(
xlfBuffer
),
path
:
project
+
"
/
"
+
iso639_2_to_3
[
language
]
+
"
/
"
+
slug
+
"
.xlf
"
}));
}
}
reject
(
slug
+
"
in
"
+
project
+
"
returned no data. Response code:
"
+
res
.
statusCode
+
"
.
"
);
reject
(
slug
+
"
in
"
+
project
+
"
returned no data. Response code:
"
+
res
.
statusCode
+
"
.
"
);
});
});
});
});
request
.
on
(
'
error
'
,
function
(
err
)
{
request
.
on
(
'
error
'
,
function
(
err
)
{
reject
(
"
Failed to query resource
"
+
slug
+
"
with the following error:
"
+
err
);
reject
(
"
Failed to query resource
"
+
slug
+
"
with the following error:
"
+
err
+
"
.
"
+
options
.
path
);
});
});
request
.
end
();
request
.
end
();
});
console
.
log
(
'
started:
'
+
options
.
path
);
});
});
}
}
function
prepareJsonFiles
()
{
function
prepareJsonFiles
()
{
var
parsePromises
=
[];
var
parsePromises
=
[];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录