Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
06ca87b3
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,发现更多精彩内容 >>
提交
06ca87b3
编写于
3月 15, 2016
作者:
D
Dirk Baeumer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes #4170: Provide a setting to define the `locale`
上级
90e5c711
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
109 addition
and
3 deletion
+109
-3
src/main.js
src/main.js
+44
-3
src/vs/workbench/browser/actions/configureLocale.ts
src/vs/workbench/browser/actions/configureLocale.ts
+64
-0
src/vs/workbench/workbench.main.js
src/vs/workbench/workbench.main.js
+1
-0
未找到文件。
src/main.js
浏览文件 @
06ca87b3
...
...
@@ -10,6 +10,33 @@ var app = require('electron').app;
var
fs
=
require
(
'
fs
'
);
var
path
=
require
(
'
path
'
);
function
stripComments
(
content
)
{
var
regexp
=
/
(
"
(?:[^\\\"]
*
(?:\\
.
)?)
*"
)
|
(
'
(?:[^\\\']
*
(?:\\
.
)?)
*'
)
|
(\/\*(?:\r?\n
|.
)
*
?\*\/)
|
(\/{2,}
.*
?(?:(?:\r?\n)
|$
))
/g
;
var
result
=
content
.
replace
(
regexp
,
function
(
match
,
m1
,
m2
,
m3
,
m4
)
{
// Only one of m1, m2, m3, m4 matches
if
(
m3
)
{
// A block comment. Replace with nothing
return
''
;
}
else
if
(
m4
)
{
// A line comment. If it ends in \r?\n then keep it.
var
length_1
=
m4
.
length
;
if
(
length_1
>
2
&&
m4
[
length_1
-
1
]
===
'
\n
'
)
{
return
m4
[
length_1
-
2
]
===
'
\r
'
?
'
\r\n
'
:
'
\n
'
;
}
else
{
return
''
;
}
}
else
{
// We match a string
return
match
;
}
});
return
result
;
};
// Duplicated in ../index.html for the renderes.
function
getNLSConfiguration
()
{
var
locale
=
undefined
;
...
...
@@ -23,6 +50,21 @@ function getNLSConfiguration() {
}
}
if
(
!
locale
)
{
var
userData
=
app
.
getPath
(
'
userData
'
);
localeConfig
=
path
.
join
(
userData
,
'
User
'
,
'
locale.json
'
);
if
(
fs
.
existsSync
(
localeConfig
))
{
try
{
var
content
=
stripComments
(
fs
.
readFileSync
(
localeConfig
,
'
utf8
'
));
value
=
JSON
.
parse
(
content
).
locale
;
if
(
value
&&
typeof
value
===
'
string
'
)
{
locale
=
value
;
}
}
catch
(
e
)
{
}
}
}
if
(
locale
===
'
pseudo
'
)
{
return
{
locale
:
locale
,
availableLanguages
:
{},
pseudo
:
true
}
}
...
...
@@ -72,10 +114,9 @@ app.on('open-file', function(event, path) {
global
.
macOpenFiles
.
push
(
path
);
});
var
nlsConfig
=
getNLSConfiguration
();
process
.
env
[
'
VSCODE_NLS_CONFIG
'
]
=
JSON
.
stringify
(
nlsConfig
);
// Load our code once ready
app
.
once
(
'
ready
'
,
function
()
{
var
nlsConfig
=
getNLSConfiguration
();
process
.
env
[
'
VSCODE_NLS_CONFIG
'
]
=
JSON
.
stringify
(
nlsConfig
);
require
(
'
./bootstrap-amd
'
).
bootstrap
(
'
vs/workbench/electron-main/main
'
);
});
src/vs/workbench/browser/actions/configureLocale.ts
0 → 100644
浏览文件 @
06ca87b3
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
nls
=
require
(
'
vs/nls
'
);
import
*
as
Path
from
'
vs/base/common/paths
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
*
as
Labels
from
'
vs/base/common/labels
'
;
import
{
Action
}
from
'
vs/base/common/actions
'
;
import
{
Registry
}
from
'
vs/platform/platform
'
;
import
{
IWorkbenchActionRegistry
,
Extensions
}
from
'
vs/workbench/common/actionRegistry
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IWorkspaceContextService
}
from
'
vs/workbench/services/workspace/common/contextService
'
;
import
{
IEditor
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
SyncActionDescriptor
}
from
'
vs/platform/actions/common/actions
'
;
class
ConfigureLocaleAction
extends
Action
{
public
static
ID
=
'
workbench.action.configureLocale
'
;
public
static
LABEL
=
nls
.
localize
(
'
configureLocale
'
,
"
Configure Locale
"
);
private
static
DEFAULT_CONTENT
:
string
=
[
'
{
'
,
`\t//
${
nls
.
localize
(
'
displayLanguage
'
,
'
Defines VSCode
\'
s display language.
'
)}
`
,
`\t//
${
nls
.
localize
(
'
restart
'
,
'
Changing the value requires to restart VSCode.
'
)}
`
,
`\t"locale":"en-US"`
,
'
}
'
].
join
(
'
\n
'
);
constructor
(
id
,
label
,
@
IFileService
private
fileService
:
IFileService
,
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
@
IWorkbenchEditorService
private
editorService
:
IWorkbenchEditorService
)
{
super
(
id
,
label
);
}
public
run
(
event
?:
any
):
TPromise
<
IEditor
>
{
let
file
=
URI
.
file
(
Path
.
join
(
this
.
contextService
.
getConfiguration
().
env
.
appSettingsHome
,
'
locale.json
'
));
return
this
.
fileService
.
resolveFile
(
file
).
then
(
null
,
(
error
)
=>
{
return
this
.
fileService
.
createFile
(
file
,
ConfigureLocaleAction
.
DEFAULT_CONTENT
);
}).
then
((
stat
)
=>
{
if
(
!
stat
)
{
return
;
}
return
this
.
editorService
.
openEditor
({
resource
:
stat
.
resource
,
options
:
{
forceOpen
:
true
}
});
},
(
error
)
=>
{
throw
new
Error
(
nls
.
localize
(
'
fail.createSettings
'
,
"
Unable to create '{0}' ({1}).
"
,
Labels
.
getPathLabel
(
file
,
this
.
contextService
),
error
));
});
}
}
let
workbenchActionsRegistry
=
<
IWorkbenchActionRegistry
>
Registry
.
as
(
Extensions
.
WorkbenchActions
);
workbenchActionsRegistry
.
registerWorkbenchAction
(
new
SyncActionDescriptor
(
ConfigureLocaleAction
,
ConfigureLocaleAction
.
ID
,
ConfigureLocaleAction
.
LABEL
));
src/vs/workbench/workbench.main.js
浏览文件 @
06ca87b3
...
...
@@ -30,6 +30,7 @@ define([
'
vs/workbench/browser/actions/triggerNavigation
'
,
'
vs/workbench/browser/actions/showPerformanceBox
'
,
'
vs/workbench/browser/actions/openSettings
'
,
'
vs/workbench/browser/actions/configureLocale
'
,
'
vs/workbench/parts/quickopen/browser/quickopen.contribution
'
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录