mirror of
https://gitlab.com/timvisee/send.git
synced 2025-12-06 22:20:55 +03:00
added L10N_DEV environment variable for making all languages available
This commit is contained in:
@@ -9,6 +9,7 @@ const conf = require('./config.js');
|
||||
const storage = require('./storage.js');
|
||||
const Raven = require('raven');
|
||||
const crypto = require('crypto');
|
||||
const fs = require('fs');
|
||||
|
||||
if (conf.sentry_dsn) {
|
||||
Raven.config(conf.sentry_dsn).install();
|
||||
@@ -22,11 +23,34 @@ const STATIC_PATH = path.join(__dirname, '../public');
|
||||
|
||||
const app = express();
|
||||
|
||||
function allLangs() {
|
||||
return fs
|
||||
.readdirSync(path.join(STATIC_PATH, 'locales'))
|
||||
.map(function(f) {
|
||||
return f.split('.')[0];
|
||||
})
|
||||
.join(',');
|
||||
}
|
||||
|
||||
function prodLangs() {
|
||||
return require(path.join(
|
||||
__dirname,
|
||||
'..',
|
||||
'package.json'
|
||||
)).availableLanguages.join(',');
|
||||
}
|
||||
|
||||
const availableLanguages = conf.l10n_dev ? allLangs() : prodLangs();
|
||||
|
||||
app.engine(
|
||||
'handlebars',
|
||||
exphbs({
|
||||
defaultLayout: 'main',
|
||||
partialsDir: 'views/partials/'
|
||||
partialsDir: 'views/partials/',
|
||||
helpers: {
|
||||
availableLanguages,
|
||||
l10nDev: conf.l10n_dev
|
||||
}
|
||||
})
|
||||
);
|
||||
app.set('view engine', 'handlebars');
|
||||
|
||||
Reference in New Issue
Block a user