Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
f00b4f10
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f00b4f10
编写于
1月 29, 2018
作者:
M
Martin Aeschlimann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[i18n] lang pack update script: add extensions list
上级
0d66fa01
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
85 addition
and
49 deletion
+85
-49
build/lib/i18n.js
build/lib/i18n.js
+33
-23
build/lib/i18n.ts
build/lib/i18n.ts
+41
-23
build/npm/update-localization-extension.js
build/npm/update-localization-extension.js
+11
-3
未找到文件。
build/lib/i18n.js
浏览文件 @
f00b4f10
...
...
@@ -42,13 +42,11 @@ exports.extraLanguages = [
];
exports
.
pseudoLanguage
=
{
id
:
'
pseudo
'
,
folderName
:
'
pseudo
'
,
transifexId
:
'
pseudo
'
};
// non built-in extensions also that are transifex and need to be part of the language packs
var
externalExtensionsWithTranslations
=
[
//"azure-account",
"
vscode-chrome-debug
"
,
"
vscode-chrome-debug-core
"
,
"
vscode-node-debug
"
,
"
vscode-node-debug2
"
];
var
externalExtensionsWithTranslations
=
{
'
vscode-chrome-debug
'
:
'
msjsdiag.debugger-for-chrome
'
,
'
vscode-node-debug
'
:
'
ms-vscode.node-debug
'
,
'
vscode-node-debug2
'
:
'
ms-vscode.node-debug2
'
};
var
LocalizeInfo
;
(
function
(
LocalizeInfo
)
{
function
is
(
value
)
{
...
...
@@ -894,7 +892,7 @@ function updateResource(project, slug, xlfFile, apiHostname, credentials) {
}
// cache resources
var
_coreAndExtensionResources
;
function
pullCoreAndExtensionsXlfFiles
(
apiHostname
,
username
,
password
,
language
,
includeE
xternalExtensions
)
{
function
pullCoreAndExtensionsXlfFiles
(
apiHostname
,
username
,
password
,
language
,
e
xternalExtensions
)
{
if
(
!
_coreAndExtensionResources
)
{
_coreAndExtensionResources
=
[];
// editor and workbench
...
...
@@ -905,15 +903,14 @@ function pullCoreAndExtensionsXlfFiles(apiHostname, username, password, language
var
extensionsToLocalize_1
=
Object
.
create
(
null
);
glob
.
sync
(
'
./extensions/**/*.nls.json
'
).
forEach
(
function
(
extension
)
{
return
extensionsToLocalize_1
[
extension
.
split
(
'
/
'
)[
2
]]
=
true
;
});
glob
.
sync
(
'
./extensions/*/node_modules/vscode-nls
'
).
forEach
(
function
(
extension
)
{
return
extensionsToLocalize_1
[
extension
.
split
(
'
/
'
)[
2
]]
=
true
;
});
if
(
includeExternalExtensions
)
{
for
(
var
_i
=
0
,
externalExtensionsWithTranslations_1
=
externalExtensionsWithTranslations
;
_i
<
externalExtensionsWithTranslations_1
.
length
;
_i
++
)
{
var
extension
=
externalExtensionsWithTranslations_1
[
_i
];
extensionsToLocalize_1
[
extension
]
=
true
;
}
}
Object
.
keys
(
extensionsToLocalize_1
).
forEach
(
function
(
extension
)
{
_coreAndExtensionResources
.
push
({
name
:
extension
,
project
:
extensionsProject
});
});
if
(
externalExtensions
)
{
for
(
var
resourceName
in
externalExtensions
)
{
_coreAndExtensionResources
.
push
({
name
:
resourceName
,
project
:
extensionsProject
});
}
}
}
return
pullXlfFiles
(
apiHostname
,
username
,
password
,
language
,
_coreAndExtensionResources
);
}
...
...
@@ -963,7 +960,7 @@ function retrieveResource(language, resource, apiHostname, credentials) {
port
:
443
,
method
:
'
GET
'
};
console
.
log
(
'
Fetching
'
+
options
.
path
);
console
.
log
(
'
[transifex]
Fetching
'
+
options
.
path
);
var
request
=
https
.
request
(
options
,
function
(
res
)
{
var
xlfBuffer
=
[];
res
.
on
(
'
data
'
,
function
(
chunk
)
{
return
xlfBuffer
.
push
(
chunk
);
});
...
...
@@ -972,7 +969,7 @@ function retrieveResource(language, resource, apiHostname, credentials) {
resolve
(
new
File
({
contents
:
Buffer
.
concat
(
xlfBuffer
),
path
:
project
+
"
/
"
+
slug
+
"
.xlf
"
}));
}
else
if
(
res
.
statusCode
===
404
)
{
console
.
log
(
slug
+
"
in
"
+
project
+
"
returned no data.
"
);
console
.
log
(
"
[transifex]
"
+
slug
+
"
in
"
+
project
+
"
returned no data.
"
);
resolve
(
null
);
}
else
{
...
...
@@ -1026,11 +1023,12 @@ function createI18nFile(originalFilePath, messages) {
});
}
var
i18nPackVersion
=
"
1.0.0
"
;
function
pullI18nPackFiles
(
apiHostname
,
username
,
password
,
language
)
{
return
pullCoreAndExtensionsXlfFiles
(
apiHostname
,
username
,
password
,
language
,
true
).
pipe
(
prepareI18nPackFiles
());
function
pullI18nPackFiles
(
apiHostname
,
username
,
password
,
language
,
resultingTranslationPaths
)
{
return
pullCoreAndExtensionsXlfFiles
(
apiHostname
,
username
,
password
,
language
,
externalExtensionsWithTranslations
)
.
pipe
(
prepareI18nPackFiles
(
externalExtensionsWithTranslations
,
resultingTranslationPaths
));
}
exports
.
pullI18nPackFiles
=
pullI18nPackFiles
;
function
prepareI18nPackFiles
()
{
function
prepareI18nPackFiles
(
externalExtensions
,
resultingTranslationPaths
)
{
var
parsePromises
=
[];
var
mainPack
=
{
version
:
i18nPackVersion
,
contents
:
{}
};
var
extensionsPacks
=
{};
...
...
@@ -1038,7 +1036,6 @@ function prepareI18nPackFiles() {
var
stream
=
this
;
var
project
=
path
.
dirname
(
xlf
.
path
);
var
resource
=
path
.
basename
(
xlf
.
path
,
'
.xlf
'
);
console
.
log
(
resource
);
var
parsePromise
=
XLF
.
parse
(
xlf
.
contents
.
toString
());
parsePromises
.
push
(
parsePromise
);
parsePromise
.
then
(
function
(
resolvedFiles
)
{
...
...
@@ -1050,9 +1047,14 @@ function prepareI18nPackFiles() {
if
(
!
extPack
)
{
extPack
=
extensionsPacks
[
resource
]
=
{
version
:
i18nPackVersion
,
contents
:
{}
};
}
var
secondSlash
=
path
.
indexOf
(
'
/
'
,
firstSlash
+
1
);
var
key
=
externalExtensionsWithTranslations
.
indexOf
(
resource
)
!==
-
1
?
path
:
path
.
substr
(
secondSlash
+
1
);
extPack
.
contents
[
key
]
=
file
.
messages
;
var
externalId
=
externalExtensions
[
resource
];
if
(
!
externalId
)
{
var
secondSlash
=
path
.
indexOf
(
'
/
'
,
firstSlash
+
1
);
extPack
.
contents
[
path
.
substr
(
secondSlash
+
1
)]
=
file
.
messages
;
}
else
{
extPack
.
contents
[
path
]
=
file
.
messages
;
}
}
else
{
mainPack
.
contents
[
path
.
substr
(
firstSlash
+
1
)]
=
file
.
messages
;
...
...
@@ -1064,10 +1066,18 @@ function prepareI18nPackFiles() {
Promise
.
all
(
parsePromises
)
.
then
(
function
()
{
var
translatedMainFile
=
createI18nFile
(
'
./main
'
,
mainPack
);
resultingTranslationPaths
.
push
({
id
:
'
vscode
'
,
resourceName
:
'
main.i18n.json
'
});
_this
.
queue
(
translatedMainFile
);
for
(
var
extension
in
extensionsPacks
)
{
var
translatedExtFile
=
createI18nFile
(
"
./extensions/
"
+
extension
,
extensionsPacks
[
extension
]);
_this
.
queue
(
translatedExtFile
);
var
externalExtensionId
=
externalExtensions
[
extension
];
if
(
externalExtensionId
)
{
resultingTranslationPaths
.
push
({
id
:
externalExtensionId
,
resourceName
:
"
extensions/
"
+
extension
+
"
.i18n.json
"
});
}
else
{
resultingTranslationPaths
.
push
({
id
:
"
vscode.
"
+
extension
,
resourceName
:
"
extensions/
"
+
extension
+
"
.i18n.json
"
});
}
}
_this
.
queue
(
null
);
})
...
...
build/lib/i18n.ts
浏览文件 @
f00b4f10
...
...
@@ -59,13 +59,12 @@ export const extraLanguages: Language[] = [
export
const
pseudoLanguage
:
Language
=
{
id
:
'
pseudo
'
,
folderName
:
'
pseudo
'
,
transifexId
:
'
pseudo
'
};
// non built-in extensions also that are transifex and need to be part of the language packs
const
externalExtensionsWithTranslations
=
[
//"azure-account",
"
vscode-chrome-debug
"
,
"
vscode-chrome-debug-core
"
,
"
vscode-node-debug
"
,
"
vscode-node-debug2
"
];
const
externalExtensionsWithTranslations
=
{
'
vscode-chrome-debug
'
:
'
msjsdiag.debugger-for-chrome
'
,
'
vscode-node-debug
'
:
'
ms-vscode.node-debug
'
,
'
vscode-node-debug2
'
:
'
ms-vscode.node-debug2
'
};
interface
Map
<
V
>
{
[
key
:
string
]:
V
;
...
...
@@ -1011,7 +1010,7 @@ function updateResource(project: string, slug: string, xlfFile: File, apiHostnam
// cache resources
let
_coreAndExtensionResources
:
Resource
[];
export
function
pullCoreAndExtensionsXlfFiles
(
apiHostname
:
string
,
username
:
string
,
password
:
string
,
language
:
Language
,
includeExternalExtensions
?:
boolean
):
NodeJS
.
ReadableStream
{
export
function
pullCoreAndExtensionsXlfFiles
(
apiHostname
:
string
,
username
:
string
,
password
:
string
,
language
:
Language
,
externalExtensions
?:
Map
<
string
>
):
NodeJS
.
ReadableStream
{
if
(
!
_coreAndExtensionResources
)
{
_coreAndExtensionResources
=
[];
// editor and workbench
...
...
@@ -1024,15 +1023,15 @@ export function pullCoreAndExtensionsXlfFiles(apiHostname: string, username: str
glob
.
sync
(
'
./extensions/**/*.nls.json
'
,
).
forEach
(
extension
=>
extensionsToLocalize
[
extension
.
split
(
'
/
'
)[
2
]]
=
true
);
glob
.
sync
(
'
./extensions/*/node_modules/vscode-nls
'
,
).
forEach
(
extension
=>
extensionsToLocalize
[
extension
.
split
(
'
/
'
)[
2
]]
=
true
);
if
(
includeExternalExtensions
)
{
for
(
let
extension
of
externalExtensionsWithTranslations
)
{
extensionsToLocalize
[
extension
]
=
true
;
}
}
Object
.
keys
(
extensionsToLocalize
).
forEach
(
extension
=>
{
_coreAndExtensionResources
.
push
({
name
:
extension
,
project
:
extensionsProject
});
});
if
(
externalExtensions
)
{
for
(
let
resourceName
in
externalExtensions
)
{
_coreAndExtensionResources
.
push
({
name
:
resourceName
,
project
:
extensionsProject
});
}
}
}
return
pullXlfFiles
(
apiHostname
,
username
,
password
,
language
,
_coreAndExtensionResources
);
}
...
...
@@ -1086,7 +1085,7 @@ function retrieveResource(language: Language, resource: Resource, apiHostname, c
port
:
443
,
method
:
'
GET
'
};
console
.
log
(
'
Fetching
'
+
options
.
path
);
console
.
log
(
'
[transifex]
Fetching
'
+
options
.
path
);
let
request
=
https
.
request
(
options
,
(
res
)
=>
{
let
xlfBuffer
:
Buffer
[]
=
[];
...
...
@@ -1095,7 +1094,7 @@ function retrieveResource(language: Language, resource: Resource, apiHostname, c
if
(
res
.
statusCode
===
200
)
{
resolve
(
new
File
({
contents
:
Buffer
.
concat
(
xlfBuffer
),
path
:
`
${
project
}
/
${
slug
}
.xlf`
}));
}
else
if
(
res
.
statusCode
===
404
)
{
console
.
log
(
`
${
slug
}
in
${
project
}
returned no data.`
);
console
.
log
(
`
[transifex]
${
slug
}
in
${
project
}
returned no data.`
);
resolve
(
null
);
}
else
{
reject
(
`
${
slug
}
in
${
project
}
returned no data. Response code:
${
res
.
statusCode
}
.`
);
...
...
@@ -1160,11 +1159,17 @@ interface I18nPack {
const
i18nPackVersion
=
"
1.0.0
"
;
export
function
pullI18nPackFiles
(
apiHostname
:
string
,
username
:
string
,
password
:
string
,
language
:
Language
):
NodeJS
.
ReadableStream
{
return
pullCoreAndExtensionsXlfFiles
(
apiHostname
,
username
,
password
,
language
,
true
).
pipe
(
prepareI18nPackFiles
());
export
interface
TranslationPath
{
id
:
string
;
resourceName
:
string
;
}
export
function
pullI18nPackFiles
(
apiHostname
:
string
,
username
:
string
,
password
:
string
,
language
:
Language
,
resultingTranslationPaths
:
TranslationPath
[]):
NodeJS
.
ReadableStream
{
return
pullCoreAndExtensionsXlfFiles
(
apiHostname
,
username
,
password
,
language
,
externalExtensionsWithTranslations
)
.
pipe
(
prepareI18nPackFiles
(
externalExtensionsWithTranslations
,
resultingTranslationPaths
));
}
export
function
prepareI18nPackFiles
(
)
{
export
function
prepareI18nPackFiles
(
externalExtensions
:
Map
<
string
>
,
resultingTranslationPaths
:
TranslationPath
[]):
NodeJS
.
ReadWriteStream
{
let
parsePromises
:
Promise
<
ParsedXLF
[]
>
[]
=
[];
let
mainPack
:
I18nPack
=
{
version
:
i18nPackVersion
,
contents
:
{}
};
let
extensionsPacks
:
Map
<
I18nPack
>
=
{};
...
...
@@ -1172,7 +1177,6 @@ export function prepareI18nPackFiles() {
let
stream
=
this
;
let
project
=
path
.
dirname
(
xlf
.
path
);
let
resource
=
path
.
basename
(
xlf
.
path
,
'
.xlf
'
);
console
.
log
(
resource
);
let
parsePromise
=
XLF
.
parse
(
xlf
.
contents
.
toString
());
parsePromises
.
push
(
parsePromise
);
parsePromise
.
then
(
...
...
@@ -1186,9 +1190,13 @@ export function prepareI18nPackFiles() {
if
(
!
extPack
)
{
extPack
=
extensionsPacks
[
resource
]
=
{
version
:
i18nPackVersion
,
contents
:
{}
};
}
const
secondSlash
=
path
.
indexOf
(
'
/
'
,
firstSlash
+
1
);
let
key
=
externalExtensionsWithTranslations
.
indexOf
(
resource
)
!==
-
1
?
path
:
path
.
substr
(
secondSlash
+
1
);
extPack
.
contents
[
key
]
=
file
.
messages
;
const
externalId
=
externalExtensions
[
resource
];
if
(
!
externalId
)
{
// internal extension: remove 'extensions/extensionId/' segnent
const
secondSlash
=
path
.
indexOf
(
'
/
'
,
firstSlash
+
1
);
extPack
.
contents
[
path
.
substr
(
secondSlash
+
1
)]
=
file
.
messages
;
}
else
{
extPack
.
contents
[
path
]
=
file
.
messages
;
}
}
else
{
mainPack
.
contents
[
path
.
substr
(
firstSlash
+
1
)]
=
file
.
messages
;
}
...
...
@@ -1199,10 +1207,20 @@ export function prepareI18nPackFiles() {
Promise
.
all
(
parsePromises
)
.
then
(()
=>
{
const
translatedMainFile
=
createI18nFile
(
'
./main
'
,
mainPack
);
resultingTranslationPaths
.
push
({
id
:
'
vscode
'
,
resourceName
:
'
main.i18n.json
'
});
this
.
queue
(
translatedMainFile
);
for
(
let
extension
in
extensionsPacks
)
{
const
translatedExtFile
=
createI18nFile
(
`./extensions/
${
extension
}
`
,
extensionsPacks
[
extension
]);
this
.
queue
(
translatedExtFile
);
const
externalExtensionId
=
externalExtensions
[
extension
];
if
(
externalExtensionId
)
{
resultingTranslationPaths
.
push
({
id
:
externalExtensionId
,
resourceName
:
`extensions/
${
extension
}
.i18n.json`
});
}
else
{
resultingTranslationPaths
.
push
({
id
:
`vscode.
${
extension
}
`
,
resourceName
:
`extensions/
${
extension
}
.i18n.json`
});
}
}
this
.
queue
(
null
);
})
...
...
build/npm/update-localization-extension.js
浏览文件 @
f00b4f10
...
...
@@ -43,7 +43,7 @@ function update(idOrPath) {
let
userName
=
localization
.
userName
||
'
api
'
;
let
apiToken
=
process
.
env
.
TRANSIFEX_API_TOKEN
;
let
languageId
=
localization
.
transifexId
||
localization
.
languageId
;
let
translationDataFolder
=
path
.
join
(
locExtFolder
,
localization
.
translations
);
let
translationDataFolder
=
path
.
join
(
locExtFolder
,
'
translations
'
);
if
(
fs
.
existsSync
(
translationDataFolder
)
&&
fs
.
existsSync
(
path
.
join
(
translationDataFolder
,
'
main.i18n.json
'
)))
{
console
.
log
(
'
Clearing
\'
'
+
translationDataFolder
+
'
\'
...
'
);
...
...
@@ -51,8 +51,16 @@ function update(idOrPath) {
}
console
.
log
(
'
Downloading translations for
\'
'
+
languageId
+
'
\'
to
\'
'
+
translationDataFolder
+
'
\'
...
'
);
i18n
.
pullI18nPackFiles
(
server
,
userName
,
apiToken
,
{
id
:
languageId
})
.
pipe
(
vfs
.
dest
(
translationDataFolder
));
const
translationPaths
=
[];
i18n
.
pullI18nPackFiles
(
server
,
userName
,
apiToken
,
{
id
:
languageId
},
translationPaths
)
.
pipe
(
vfs
.
dest
(
translationDataFolder
)).
on
(
'
end
'
,
function
()
{
localization
.
translations
=
[];
for
(
let
tp
of
translationPaths
)
{
localization
.
translations
.
push
({
id
:
tp
.
id
,
path
:
`./translations/
${
tp
.
resourceName
}
`
});
}
fs
.
writeFileSync
(
path
.
join
(
locExtFolder
,
'
package.json
'
),
JSON
.
stringify
(
packageJSON
,
null
,
'
\t
'
));
});
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录