mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-11-03 20:45:58 +01:00 
			
		
		
		
	cleaned languages.js
This commit is contained in:
		@@ -1,3 +1,5 @@
 | 
				
			|||||||
 | 
					'use strict';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var	fs = require('fs'),
 | 
					var	fs = require('fs'),
 | 
				
			||||||
	path = require('path'),
 | 
						path = require('path'),
 | 
				
			||||||
	async = require('async'),
 | 
						async = require('async'),
 | 
				
			||||||
@@ -9,29 +11,34 @@ Languages.list = function(callback) {
 | 
				
			|||||||
		languages = [];
 | 
							languages = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	fs.readdir(languagesPath, function(err, files) {
 | 
						fs.readdir(languagesPath, function(err, files) {
 | 
				
			||||||
 | 
							if (err) {
 | 
				
			||||||
 | 
								return callback(err);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		async.each(files, function(folder, next) {
 | 
							async.each(files, function(folder, next) {
 | 
				
			||||||
			fs.stat(path.join(languagesPath, folder), function(err, stat) {
 | 
								fs.stat(path.join(languagesPath, folder), function(err, stat) {
 | 
				
			||||||
				if (!err) {
 | 
									if (err) {
 | 
				
			||||||
					if (stat.isDirectory()) {
 | 
										return next(err);
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									if (!stat.isDirectory()) {
 | 
				
			||||||
 | 
										return next();
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				var configPath = path.join(languagesPath, folder, 'language.json');
 | 
									var configPath = path.join(languagesPath, folder, 'language.json');
 | 
				
			||||||
						fs.exists(configPath, function(exists) {
 | 
					
 | 
				
			||||||
							if (exists) {
 | 
					 | 
				
			||||||
				fs.readFile(configPath, function(err, stream) {
 | 
									fs.readFile(configPath, function(err, stream) {
 | 
				
			||||||
 | 
										if (err) {
 | 
				
			||||||
 | 
											next();
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
					languages.push(JSON.parse(stream.toString()));
 | 
										languages.push(JSON.parse(stream.toString()));
 | 
				
			||||||
					next();
 | 
										next();
 | 
				
			||||||
				});
 | 
									});
 | 
				
			||||||
							} else {
 | 
					 | 
				
			||||||
								next();
 | 
					 | 
				
			||||||
							}
 | 
					 | 
				
			||||||
						});
 | 
					 | 
				
			||||||
					} else {
 | 
					 | 
				
			||||||
						next();
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				} else {
 | 
					 | 
				
			||||||
					next();
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			});
 | 
								});
 | 
				
			||||||
		}, function(err) {
 | 
							}, function(err) {
 | 
				
			||||||
 | 
								if (err) {
 | 
				
			||||||
 | 
									return callback(err);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
			// Sort alphabetically
 | 
								// Sort alphabetically
 | 
				
			||||||
			languages = languages.sort(function(a, b) {
 | 
								languages = languages.sort(function(a, b) {
 | 
				
			||||||
				return a.code > b.code ? 1 : -1;
 | 
									return a.code > b.code ? 1 : -1;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user