3 var env = require('gitter-web-env');
4 var config = env.config;
5 var I18n = require('i18n-2');
6 var path = require('path');
7 var fs = require('fs');
8 var translations = require('gitter-web-translations');
10 var devMode = config.runtimeEnvironment === 'dev';
12 function getLocales(localeDir) {
13 var files = fs.readdirSync(localeDir);
14 /* EN must always appear first */
17 .filter(function(file) {
18 var fullName = path.join(localeDir, file);
19 return fs.statSync(fullName).isFile() && path.extname(file) === '.json';
22 return path.basename(file, '.json');
24 .filter(function(lang) {
30 var messagesPath = translations.getMessagesPath();
31 var messageLocales = getLocales(messagesPath);
33 var homepagePath = translations.getHomePagePath();
34 var homepageLocales = getLocales(homepagePath);
39 locales: messageLocales,
42 directory: messagesPath,
48 getLocales: function() {
49 return messageLocales;
52 getHomePage: function(req) {
54 locales: homepageLocales,
57 directory: homepagePath,