diff --git a/locale/en.json b/locale/en.json
new file mode 100644
index 0000000000000000000000000000000000000000..2419a18c10b0cf974e36940625c6432748555546
--- /dev/null
+++ b/locale/en.json
@@ -0,0 +1,23 @@
+{
+ "Soutenez La Quadrature du Net !": "Support La Quadrature du Net!",
+ "CHOISIR AU HASARD": "RANDOMIZE",
+ "ÉTAPE SUIVANTE": "NEXT STEP",
+ "Choisissez 2 couleurs": "Choose 2 colors",
+ "Choisissez la couleur de fond": "Choose the background color",
+ "Choisissez la couleur du texte": "Choose the text color",
+ "Remplissez le texte à trou": "Fill the blanked text",
+ "(90 caractères maximum)": "(90 characters max)",
+ "Choisissez votre police": "Choose your font",
+ "Choisissez votre icône": "Choose your icon",
+ "Signez votre création ! (optionnel)": "Sign your creation! (optional)",
+ "Pas de javascript ? Pas de problème !
Ce générateur fonctionne parfaitement sans javascript, seule la prévisualisation du rendu dans le navigateur est désactivée.": "No javascript? No problem!
This generator is working perfectly without javscript. The only missing feature is the preview of the rendered image.",
+ "Tweet": "Tweet",
+ "Partager": "Share",
+ "Enregistrer": "Save",
+ "Crédits :": "Credits:",
+ "Les polices utilisées viennnent de": "Used fonts come from",
+ "par": "by",
+ "et": "and",
+ "Site hébergé par": "Website hosted by",
+ "Code source du site :": "Website source code:"
+}
diff --git a/srv.js b/srv.js
index 3c1792c567b6bd4bba59abee8362fae3e4e37c33..29940880866550ceb93b9c2fdad2f1b5de37498d 100755
--- a/srv.js
+++ b/srv.js
@@ -7,11 +7,13 @@ const Canvas = require('canvas');
const Image = Canvas.Image;
const app = express();
const config = require('./config.json');
+const enLocale = require('./locale/en.json');
app.set('x-powered-by', false);
app.set('view engine', 'ejs');
app.use(express.static('./static'));
+
// {name: filepath}
let fonts = {
'FiraSans': 'FiraSans-Regular.otf',
@@ -149,11 +151,28 @@ app.get('/generate.png', function (req, res) {
})
});
+let i18n = (function(){
+ let _locale = 'en';
+
+ this._ = function(str) {
+ return _locale == 'en' ? enLocale[str] || str : str;
+ }
+
+ this.setLocale = function(locale) {
+ _locale = locale;
+ }
+
+ return this;
+})();
+
app.get('/', function(req, res) {
+ let locale = req.headers['accept-language'] || '';
+ i18n.setLocale(locale.indexOf('en') !== -1 && locale.indexOf('en') < locale.indexOf('fr') ? 'en' : 'fr');
res.render('index', {protocol: req.protocol,
host: req.headers.host,
imageParams: req._parsedUrl.query,
- subdir: config.subdir});
+ subdir: config.subdir,
+ _: i18n._});
})
app.listen(process.env.PORT || config.port || 80);
diff --git a/views/index.ejs b/views/index.ejs
index 2d9cb463393608723c97bc378157a32df2ed11e4..71a4d55204a9458bc168b2ee4ef4fb606c577dd6 100644
--- a/views/index.ejs
+++ b/views/index.ejs
@@ -13,7 +13,7 @@
-