Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
4abe8749
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,发现更多精彩内容 >>
提交
4abe8749
编写于
1月 26, 2018
作者:
M
Martin Aeschlimann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[i18n] fix paths for external extensions
上级
6bfc7ee2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
38 addition
and
43 deletion
+38
-43
build/lib/i18n.js
build/lib/i18n.js
+18
-22
build/lib/i18n.ts
build/lib/i18n.ts
+19
-20
build/npm/update-localization-extension.js
build/npm/update-localization-extension.js
+1
-1
未找到文件。
build/lib/i18n.js
浏览文件 @
4abe8749
...
...
@@ -894,7 +894,7 @@ function updateResource(project, slug, xlfFile, apiHostname, credentials) {
}
// cache resources
var
_coreAndExtensionResources
;
function
pullCoreAndExtensionsXlfFiles
(
apiHostname
,
username
,
password
,
language
)
{
function
pullCoreAndExtensionsXlfFiles
(
apiHostname
,
username
,
password
,
language
,
includeExternalExtensions
)
{
if
(
!
_coreAndExtensionResources
)
{
_coreAndExtensionResources
=
[];
// editor and workbench
...
...
@@ -905,9 +905,11 @@ 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
;
});
for
(
var
_i
=
0
,
externalExtensionsWithTranslations_1
=
externalExtensionsWithTranslations
;
_i
<
externalExtensionsWithTranslations_1
.
length
;
_i
++
)
{
var
extension
=
externalExtensionsWithTranslations_1
[
_i
];
extensionsToLocalize_1
[
extension
]
=
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
});
...
...
@@ -1025,7 +1027,7 @@ function createI18nFile(originalFilePath, messages) {
}
var
i18nPackVersion
=
"
1.0.0
"
;
function
pullI18nPackFiles
(
apiHostname
,
username
,
password
,
language
)
{
return
pullCoreAndExtensionsXlfFiles
(
apiHostname
,
username
,
password
,
language
).
pipe
(
prepareI18nPackFiles
());
return
pullCoreAndExtensionsXlfFiles
(
apiHostname
,
username
,
password
,
language
,
true
).
pipe
(
prepareI18nPackFiles
());
}
exports
.
pullI18nPackFiles
=
pullI18nPackFiles
;
function
prepareI18nPackFiles
()
{
...
...
@@ -1034,32 +1036,26 @@ function prepareI18nPackFiles() {
var
extensionsPacks
=
{};
return
event_stream_1
.
through
(
function
(
xlf
)
{
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
)
{
resolvedFiles
.
forEach
(
function
(
file
)
{
var
path
=
file
.
originalFilePath
;
var
firstSlash
=
path
.
indexOf
(
'
/
'
);
var
firstSegment
=
path
.
substr
(
0
,
firstSlash
);
if
(
firstSegment
===
'
src
'
)
{
mainPack
.
contents
[
path
.
substr
(
firstSlash
+
1
)]
=
file
.
messages
;
}
else
if
(
firstSegment
===
'
extensions
'
)
{
var
secondSlash
=
path
.
indexOf
(
'
/
'
,
firstSlash
+
1
);
var
secondSegment
=
path
.
substring
(
firstSlash
+
1
,
secondSlash
);
if
(
secondSegment
)
{
var
extPack
=
extensionsPacks
[
secondSegment
];
if
(
!
extPack
)
{
extPack
=
extensionsPacks
[
secondSegment
]
=
{
version
:
i18nPackVersion
,
contents
:
{}
};
}
extPack
.
contents
[
path
.
substr
(
secondSlash
+
1
)]
=
file
.
messages
;
}
else
{
console
.
log
(
'
Unknown second segment
'
+
path
);
if
(
project
===
extensionsProject
)
{
var
extPack
=
extensionsPacks
[
resource
];
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
;
}
else
{
console
.
log
(
'
Unknown first segment
'
+
path
)
;
mainPack
.
contents
[
path
.
substr
(
firstSlash
+
1
)]
=
file
.
messages
;
}
});
});
...
...
build/lib/i18n.ts
浏览文件 @
4abe8749
...
...
@@ -60,7 +60,7 @@ export const pseudoLanguage: Language = { id: 'pseudo', folderName: 'pseudo', tr
// non built-in extensions also that are transifex and need to be part of the language packs
const
externalExtensionsWithTranslations
=
[
"
azure-account
"
,
//
"azure-account",
"
vscode-chrome-debug
"
,
"
vscode-chrome-debug-core
"
,
"
vscode-node-debug
"
,
...
...
@@ -1011,7 +1011,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
):
NodeJS
.
ReadableStream
{
export
function
pullCoreAndExtensionsXlfFiles
(
apiHostname
:
string
,
username
:
string
,
password
:
string
,
language
:
Language
,
includeExternalExtensions
?:
boolean
):
NodeJS
.
ReadableStream
{
if
(
!
_coreAndExtensionResources
)
{
_coreAndExtensionResources
=
[];
// editor and workbench
...
...
@@ -1024,8 +1024,10 @@ 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
);
for
(
let
extension
of
externalExtensionsWithTranslations
)
{
extensionsToLocalize
[
extension
]
=
true
;
if
(
includeExternalExtensions
)
{
for
(
let
extension
of
externalExtensionsWithTranslations
)
{
extensionsToLocalize
[
extension
]
=
true
;
}
}
Object
.
keys
(
extensionsToLocalize
).
forEach
(
extension
=>
{
...
...
@@ -1159,7 +1161,7 @@ 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
).
pipe
(
prepareI18nPackFiles
());
return
pullCoreAndExtensionsXlfFiles
(
apiHostname
,
username
,
password
,
language
,
true
).
pipe
(
prepareI18nPackFiles
());
}
export
function
prepareI18nPackFiles
()
{
...
...
@@ -1168,6 +1170,9 @@ export function prepareI18nPackFiles() {
let
extensionsPacks
:
Map
<
I18nPack
>
=
{};
return
through
(
function
(
this
:
ThroughStream
,
xlf
:
File
)
{
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
(
...
...
@@ -1175,23 +1180,17 @@ export function prepareI18nPackFiles() {
resolvedFiles
.
forEach
(
file
=>
{
const
path
=
file
.
originalFilePath
;
const
firstSlash
=
path
.
indexOf
(
'
/
'
);
const
firstSegment
=
path
.
substr
(
0
,
firstSlash
);
if
(
firstSegment
===
'
src
'
)
{
mainPack
.
contents
[
path
.
substr
(
firstSlash
+
1
)]
=
file
.
messages
;
}
else
if
(
firstSegment
===
'
extensions
'
)
{
const
secondSlash
=
path
.
indexOf
(
'
/
'
,
firstSlash
+
1
);
const
secondSegment
=
path
.
substring
(
firstSlash
+
1
,
secondSlash
);
if
(
secondSegment
)
{
let
extPack
=
extensionsPacks
[
secondSegment
];
if
(
!
extPack
)
{
extPack
=
extensionsPacks
[
secondSegment
]
=
{
version
:
i18nPackVersion
,
contents
:
{}
};
}
extPack
.
contents
[
path
.
substr
(
secondSlash
+
1
)]
=
file
.
messages
;
}
else
{
console
.
log
(
'
Unknown second segment
'
+
path
);
if
(
project
===
extensionsProject
)
{
let
extPack
=
extensionsPacks
[
resource
];
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
;
}
else
{
console
.
log
(
'
Unknown first segment
'
+
path
)
;
mainPack
.
contents
[
path
.
substr
(
firstSlash
+
1
)]
=
file
.
messages
;
}
});
}
...
...
build/npm/update-localization-extension.js
浏览文件 @
4abe8749
...
...
@@ -19,7 +19,7 @@ function update(idOrPath) {
}
let
locExtFolder
=
idOrPath
;
if
(
/^
\w{2}(
-
\w
+
)?
$/
.
test
(
idOrPath
))
{
locExtFolder
=
'
../vscode-l
ocalization
-
'
+
idOrPath
;
locExtFolder
=
'
../vscode-l
anguage-pack
-
'
+
idOrPath
;
}
let
locExtStat
=
fs
.
statSync
(
locExtFolder
);
if
(
!
locExtStat
||
!
locExtStat
.
isDirectory
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录