From 7c33b2e5cbaa88db978dce4830d2a705b22ceae4 Mon Sep 17 00:00:00 2001 From: Toam Date: Sun, 3 Nov 2013 13:54:42 +0100 Subject: [PATCH] init localisation --- .gitignore | 4 +++- client/main.js | 14 ++++++++++++++ client/models/setting.js | 1 + client/views/posts/post_item.html | 12 ++++++------ lib/locales/en.js | 16 ++++++++++++++++ lib/locales/fr.js | 16 ++++++++++++++++ 6 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 lib/locales/en.js create mode 100644 lib/locales/fr.js diff --git a/.gitignore b/.gitignore index 6087d632e..1e3a56c2d 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,6 @@ codekit-config.json config.rb -deploy.sh \ No newline at end of file +deploy.sh + +.idea \ No newline at end of file diff --git a/client/main.js b/client/main.js index 2f11d40b8..8913b437b 100644 --- a/client/main.js +++ b/client/main.js @@ -9,6 +9,20 @@ Meteor.subscribe('settings', function(){ // runs once on site load analyticsInit(); Session.set('settingsLoaded',true); + + // Localisation + i18n.init({ + lng: getSetting("language"), + resStore: eval(getSetting("language")), + saveMissing: true, + debug: true + }); + + Handlebars.registerHelper('i18n', + function(str){ + return (i18n != undefined ? i18n.t(str) : str); + } + ); }); // Categories diff --git a/client/models/setting.js b/client/models/setting.js index 2132f434e..e3e104432 100644 --- a/client/models/setting.js +++ b/client/models/setting.js @@ -15,6 +15,7 @@ Setting = FormModel.extend({ logoHeight: '', logoWidth: '', defaultEmail: '', + language: 'en', newPostsNotifications: true, backgroundColor: '', secondaryColor: '', diff --git a/client/views/posts/post_item.html b/client/views/posts/post_item.html index c80752563..aa66c906a 100644 --- a/client/views/posts/post_item.html +++ b/client/views/posts/post_item.html @@ -1,7 +1,7 @@