mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-30 18:46:01 +01:00 
			
		
		
		
	added icons to all h1s in admin panel
languages tab in ACP each language now also has a "language.json"
This commit is contained in:
		
							
								
								
									
										51
									
								
								src/languages.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								src/languages.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,51 @@ | ||||
| var	fs = require('fs'), | ||||
| 	path = require('path'), | ||||
| 	async = require('async'), | ||||
|  | ||||
| 	Languages = {}; | ||||
|  | ||||
| Languages.list = function(callback) { | ||||
| 	var	languagesPath = path.join(__dirname, '../public/language'), | ||||
| 		languages = []; | ||||
|  | ||||
| 	fs.readdir(languagesPath, function(err, files) { | ||||
| 		async.each(files, function(folder, next) { | ||||
| 			fs.stat(path.join(languagesPath, folder), function(err, stat) { | ||||
| 				if (!err) { | ||||
| 					if (stat.isDirectory()) { | ||||
| 						var configPath = path.join(languagesPath, folder, 'language.json'); | ||||
| 						fs.exists(configPath, function(exists) { | ||||
| 							if (exists) { | ||||
| 								fs.readFile(configPath, function(err, stream) { | ||||
| 									languages.push(JSON.parse(stream.toString())); | ||||
| 									next(); | ||||
| 								}); | ||||
| 							} else { | ||||
| 								next(); | ||||
| 							} | ||||
| 						}); | ||||
| 					} else { | ||||
| 						next(); | ||||
| 					} | ||||
| 				} else { | ||||
| 					next(); | ||||
| 				} | ||||
| 			}); | ||||
| 		}, function(err) { | ||||
| 			// Float "en" to the top | ||||
| 			languages = languages.sort(function(a, b) { | ||||
| 				if (a.code === 'en') { | ||||
| 					return -1; | ||||
| 				} else if (b.code === 'en') { | ||||
| 					return 1; | ||||
| 				} else { | ||||
| 					return 0; | ||||
| 				} | ||||
| 			}); | ||||
|  | ||||
| 			callback(err, languages); | ||||
| 		}); | ||||
| 	}); | ||||
| }; | ||||
|  | ||||
| module.exports = Languages; | ||||
		Reference in New Issue
	
	Block a user