From 4565342b057e7d9d354969b8148eee245f4cfed3 Mon Sep 17 00:00:00 2001 From: Hiroyasu Nishiyama Date: Sun, 27 May 2018 01:38:54 +0900 Subject: [PATCH] add i18n support for project default files generation --- red/runtime/locales/en-US/runtime.json | 4 +++- red/runtime/locales/ja/runtime.json | 10 ++++++++++ .../storage/localfilesystem/projects/Project.js | 4 ++-- .../localfilesystem/projects/defaultFileSet.js | 11 ++++++----- 4 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 red/runtime/locales/ja/runtime.json diff --git a/red/runtime/locales/en-US/runtime.json b/red/runtime/locales/en-US/runtime.json index 2b04a26b7..6e9f057ae 100644 --- a/red/runtime/locales/en-US/runtime.json +++ b/red/runtime/locales/en-US/runtime.json @@ -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." } } } diff --git a/red/runtime/locales/ja/runtime.json b/red/runtime/locales/ja/runtime.json new file mode 100644 index 000000000..87e3fe0cb --- /dev/null +++ b/red/runtime/locales/ja/runtime.json @@ -0,0 +1,10 @@ +{ + "storage": { + "localfilesystem": { + "projects": { + "summary": "Node-REDプロジェクト", + "readme": "### 説明\nこれはプロジェクトのREADME.mdファイルです。このファイルには、\nプロジェクトの説明、利用方法、その他の情報を記載します。" + } + } + } +} diff --git a/red/runtime/storage/localfilesystem/projects/Project.js b/red/runtime/storage/localfilesystem/projects/Project.js index 8ba85f768..989774d6c 100644 --- a/red/runtime/storage/localfilesystem/projects/Project.js +++ b/red/runtime/storage/localfilesystem/projects/Project.js @@ -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))); } } diff --git a/red/runtime/storage/localfilesystem/projects/defaultFileSet.js b/red/runtime/storage/localfilesystem/projects/defaultFileSet.js index 12368ec75..a7e825207 100644 --- a/red/runtime/storage/localfilesystem/projects/defaultFileSet.js +++ b/red/runtime/storage/localfilesystem/projects/defaultFileSet.js @@ -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" ;}