mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Merge pull request #1744 from node-red-hitachi/0.19-i18n-defaultFileSet
Add i18n support for default file set for a project
This commit is contained in:
		| @@ -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." | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|   | ||||
							
								
								
									
										10
									
								
								red/runtime/locales/ja/runtime.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								red/runtime/locales/ja/runtime.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| { | ||||
|     "storage": { | ||||
|         "localfilesystem": { | ||||
|             "projects": { | ||||
|                 "summary": "Node-REDプロジェクト", | ||||
|                 "readme": "### 説明\nこれはプロジェクトのREADME.mdファイルです。このファイルには、\nプロジェクトの説明、利用方法、その他の情報を記載します。" | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -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))); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -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" ;} | ||||
|   | ||||
| @@ -19,6 +19,13 @@ var should = require("should"); | ||||
| var defaultFileSet = require("../../../../../../red/runtime/storage/localfilesystem/projects/defaultFileSet"); | ||||
|  | ||||
| describe('storage/localfilesystem/projects/defaultFileSet', function() { | ||||
|     var runtime = { | ||||
|         i18n: { | ||||
|             "_": function(name) { | ||||
|                 return name; | ||||
|             } | ||||
|         } | ||||
|     }; | ||||
|     it('generates package.json for a project', function() { | ||||
|         var generated = defaultFileSet["package.json"]({ | ||||
|             name: "A TEST NAME", | ||||
| @@ -27,7 +34,7 @@ describe('storage/localfilesystem/projects/defaultFileSet', function() { | ||||
|                 flow: "MY FLOW FILE", | ||||
|                 credentials: "MY CREDENTIALS FILE" | ||||
|             } | ||||
|         }); | ||||
|         }, runtime); | ||||
|  | ||||
|         var parsed = JSON.parse(generated); | ||||
|         parsed.should.have.property('name',"A TEST NAME"); | ||||
| @@ -42,7 +49,7 @@ describe('storage/localfilesystem/projects/defaultFileSet', function() { | ||||
|         var generated = defaultFileSet["README.md"]({ | ||||
|             name: "A TEST NAME", | ||||
|             summary: "A TEST SUMMARY" | ||||
|         }); | ||||
|         }, runtime); | ||||
|         generated.should.match(/A TEST NAME/); | ||||
|         generated.should.match(/A TEST SUMMARY/); | ||||
|     }); | ||||
| @@ -50,7 +57,7 @@ describe('storage/localfilesystem/projects/defaultFileSet', function() { | ||||
|         var generated = defaultFileSet[".gitignore"]({ | ||||
|             name: "A TEST NAME", | ||||
|             summary: "A TEST SUMMARY" | ||||
|         }); | ||||
|         }, runtime); | ||||
|         generated.length.should.be.greaterThan(0); | ||||
|     }); | ||||
| }); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user