diff --git a/package.json b/package.json
index ccc149da..696e57da 100644
--- a/package.json
+++ b/package.json
@@ -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",
diff --git a/server/config.js b/server/config.js
index 5c6e540a..83e3e21e 100644
--- a/server/config.js
+++ b/server/config.js
@@ -46,6 +46,11 @@ const conf = convict({
format: Number,
default: 86400,
env: 'EXPIRE_SECONDS'
+ },
+ l10n_dev: {
+ format: Boolean,
+ default: false,
+ env: 'L10N_DEV'
}
});
diff --git a/server/server.js b/server/server.js
index 49fbe7e0..b12f3f57 100644
--- a/server/server.js
+++ b/server/server.js
@@ -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');
diff --git a/views/layouts/main.handlebars b/views/layouts/main.handlebars
index cf00952f..4609d7c3 100644
--- a/views/layouts/main.handlebars
+++ b/views/layouts/main.handlebars
@@ -8,7 +8,7 @@
-
+