1
0
mirror of https://gitlab.com/timvisee/send.git synced 2024-11-10 21:22:35 +01:00

Merge pull request #314 from mozilla/i312

added L10N_DEV environment variable for making all languages available
This commit is contained in:
Danny Coates 2017-07-25 15:59:31 -07:00 committed by GitHub
commit f20c995d1a
4 changed files with 32 additions and 2 deletions

View File

@ -45,6 +45,7 @@
"homepage": "https://github.com/mozilla/send/",
"license": "MPL-2.0",
"repository": "mozilla/send",
"availableLanguages": ["en-US"],
"scripts": {
"build": "npm-run-all build:*",
"build:upload": "browserify frontend/src/upload.js -g uglifyify -o public/upload.js",

View File

@ -46,6 +46,11 @@ const conf = convict({
format: Number,
default: 86400,
env: 'EXPIRE_SECONDS'
},
l10n_dev: {
format: Boolean,
default: false,
env: 'L10N_DEV'
}
});

View File

@ -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');

View File

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<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="localization" href="/locales/{locale}/send.ftl">