forked from MapComplete/MapComplete
		
	Stricter formatting of translation files: sort general files by key
This commit is contained in:
		
							parent
							
								
									d5904b1714
								
							
						
					
					
						commit
						2974f8638b
					
				
					 21 changed files with 4142 additions and 4124 deletions
				
			
		|  | @ -274,11 +274,29 @@ function transformTranslation(obj: any, depth = 1) { | |||
| 
 | ||||
| } | ||||
| 
 | ||||
| function sortKeys(o: object): object{ | ||||
|     const keys = Object.keys(o) | ||||
|     keys.sort() | ||||
|     const nw = {} | ||||
|     for (const key of keys) { | ||||
|         const v = o[key] | ||||
|         if(typeof v === "object"){ | ||||
|             nw[key] = sortKeys(v) | ||||
|         }else{ | ||||
|             nw[key] = v | ||||
|         } | ||||
|     } | ||||
|     return nw | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Formats the specified file, helps to prevent merge conflicts | ||||
|  * */ | ||||
| function formatFile(path) { | ||||
|     const contents = JSON.parse(readFileSync(path, "utf8")) | ||||
|     let contents = JSON.parse(readFileSync(path, "utf8")) | ||||
|      | ||||
|     contents = sortKeys(contents) | ||||
|      | ||||
|     writeFileSync(path, JSON.stringify(contents, null, "    ")) | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue