added L10N_DEV environment variable for making all languages available
This commit is contained in:
parent
93930b91a2
commit
7fd8fb4914
|
@ -45,6 +45,7 @@
|
||||||
"homepage": "https://github.com/mozilla/send/",
|
"homepage": "https://github.com/mozilla/send/",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"repository": "mozilla/send",
|
"repository": "mozilla/send",
|
||||||
|
"availableLanguages": ["en-US"],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "npm-run-all build:*",
|
"build": "npm-run-all build:*",
|
||||||
"build:upload": "browserify frontend/src/upload.js -g uglifyify -o public/upload.js",
|
"build:upload": "browserify frontend/src/upload.js -g uglifyify -o public/upload.js",
|
||||||
|
|
|
@ -46,6 +46,11 @@ const conf = convict({
|
||||||
format: Number,
|
format: Number,
|
||||||
default: 86400,
|
default: 86400,
|
||||||
env: 'EXPIRE_SECONDS'
|
env: 'EXPIRE_SECONDS'
|
||||||
|
},
|
||||||
|
l10n_dev: {
|
||||||
|
format: Boolean,
|
||||||
|
default: false,
|
||||||
|
env: 'L10N_DEV'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ const conf = require('./config.js');
|
||||||
const storage = require('./storage.js');
|
const storage = require('./storage.js');
|
||||||
const Raven = require('raven');
|
const Raven = require('raven');
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
if (conf.sentry_dsn) {
|
if (conf.sentry_dsn) {
|
||||||
Raven.config(conf.sentry_dsn).install();
|
Raven.config(conf.sentry_dsn).install();
|
||||||
|
@ -22,11 +23,34 @@ const STATIC_PATH = path.join(__dirname, '../public');
|
||||||
|
|
||||||
const app = express();
|
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(
|
app.engine(
|
||||||
'handlebars',
|
'handlebars',
|
||||||
exphbs({
|
exphbs({
|
||||||
defaultLayout: 'main',
|
defaultLayout: 'main',
|
||||||
partialsDir: 'views/partials/'
|
partialsDir: 'views/partials/',
|
||||||
|
helpers: {
|
||||||
|
availableLanguages,
|
||||||
|
l10nDev: conf.l10n_dev
|
||||||
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
app.set('view engine', 'handlebars');
|
app.set('view engine', 'handlebars');
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
<meta name="defaultLanguage" content="en-US">
|
<meta name="defaultLanguage" content="en-US">
|
||||||
<meta name="availableLanguages" content="en-US">
|
<meta name="availableLanguages" content="{{availableLanguages}}">
|
||||||
|
|
||||||
<link rel="icon" type="image/png" href="/resources/favicon-32x32.png" sizes="32x32" />
|
<link rel="icon" type="image/png" href="/resources/favicon-32x32.png" sizes="32x32" />
|
||||||
<link rel="localization" href="/locales/{locale}/send.ftl">
|
<link rel="localization" href="/locales/{locale}/send.ftl">
|
||||||
|
|
Loading…
Reference in New Issue