1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

add i18n support for project default files generation

This commit is contained in:
Hiroyasu Nishiyama 2018-05-27 01:38:54 +09:00
parent 0ad54cc2d1
commit 4565342b05
4 changed files with 21 additions and 8 deletions

View File

@ -150,7 +150,9 @@
"disabled": "Projects disabled : editorTheme.projects.enabled=false",
"disabledNoFlag": "Projects disabled : set editorTheme.projects.enabled=true to enable",
"git-not-found": "Projects disabled : git command not found",
"git-version-old": "Projects disabled : git __version__ not supported. Requires 2.x"
"git-version-old": "Projects disabled : git __version__ not supported. Requires 2.x",
"summary": "A Node-RED Project",
"readme": "### About\n\nThis is your project's README.md file. It helps users understand what your\nproject does, how to use it and anything else they may need to know."
}
}
}

View File

@ -0,0 +1,10 @@
{
"storage": {
"localfilesystem": {
"projects": {
"summary": "Node-REDプロジェクト",
"readme": "### 説明\nこれはプロジェクトのREADME.mdファイルです。このファイルには、\nプロジェクトの説明、利用方法、その他の情報を記載します。"
}
}
}
}

View File

@ -162,7 +162,7 @@ Project.prototype.initialise = function(user,data) {
if (defaultFileSet.hasOwnProperty(file)) {
var path = fspath.join(project.path,file);
if (!fs.existsSync(path)) {
promises.push(util.writeFile(path,defaultFileSet[file](project)));
promises.push(util.writeFile(path,defaultFileSet[file](project, runtime)));
}
}
@ -850,7 +850,7 @@ function createDefaultProject(user, project) {
}
for (var file in defaultFileSet) {
if (defaultFileSet.hasOwnProperty(file)) {
promises.push(util.writeFile(fspath.join(projectPath,file),defaultFileSet[file](project)));
promises.push(util.writeFile(fspath.join(projectPath,file),defaultFileSet[file](project, runtime)));
}
}

View File

@ -15,10 +15,11 @@
**/
module.exports = {
"package.json": function(project) {
"package.json": function(project, runtime) {
var i18n = runtime.i18n;
var package = {
"name": project.name,
"description": project.summary||"A Node-RED Project",
"description": project.summary||i18n._("storage.localfilesystem.projects.summary"),
"version": "0.0.1",
"dependencies": {},
"node-red": {
@ -34,13 +35,13 @@ module.exports = {
}
return JSON.stringify(package,"",4);
},
"README.md": function(project) {
"README.md": function(project, runtime) {
var i18n = runtime.i18n;
var content = project.name+"\n"+("=".repeat(project.name.length))+"\n\n";
if (project.summary) {
content += project.summary+"\n\n";
}
content += "### About\n\nThis is your project's README.md file. It helps users understand what your\nproject does, how to use it and anything else they may need to know.";
content += i18n._("storage.localfilesystem.projects.readme");
return content;
},
".gitignore": function() { return "*.backup" ;}