Last active
June 19, 2023 07:47
Revisions
-
mashpie revised this gist
Apr 28, 2013 . 1 changed file with 0 additions and 10 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,16 +21,6 @@ app.configure(function () { // i18n init parses req for language headers, cookies, etc. app.use(i18n.init); }); // serving homepage -
mashpie revised this gist
Mar 18, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ i18n.configure({ // setup some locales - other locales default to en silently locales: ['en', 'ru', 'de'], // sets a custom cookie name to parse locale settings from cookie: 'yourcookiename', // where to store json files - defaults to './locales' -
mashpie revised this gist
Mar 18, 2013 . 1 changed file with 1 addition and 4 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,10 +7,7 @@ i18n.configure({ // setup some locales - other locales default to en silently locales: ['en', 'ru', 'de'], // sets a custom cookie name to parse locale settings from cookie: 'yourcookiename', // where to store json files - defaults to './locales' -
mashpie revised this gist
Mar 18, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ i18n.configure({ cookie: 'yourcookiename', // where to store json files - defaults to './locales' directory: __dirname + '/locales' }); app.configure(function () { -
mashpie revised this gist
Mar 18, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ { "name": "i18n-express-cookie-example", "version": "0.0.0", "author": "Marcus Spiegel <marcus.spiegel@gmail.com>", "dependencies": { -
mashpie revised this gist
Mar 18, 2013 . 1 changed file with 1 addition and 10 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,19 +14,10 @@ i18n.configure({ cookie: 'yourcookiename', // where to store json files - defaults to './locales' directory: './configs/locale' }); app.configure(function () { // you will need to use cookieParser to expose cookies to req.cookies app.use(express.cookieParser()); -
mashpie renamed this gist
Mar 9, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
mashpie created this gist
Mar 9, 2013 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,56 @@ // usual requirements var express = require('express'), i18n = require('i18n'), app = module.exports = express(); i18n.configure({ // setup some locales - other locales default to en silently locales: ['en', 'ru', 'de'], // you may alter a site wide default locale defaultLocale: 'en', // sets a custom cookie name to parse locale settings from cookie: 'yourcookiename', // where to store json files - defaults to './locales' directory: './configs/locale', // enabled some debug output - defaults to false debug: true }); app.configure(function () { // nice favicon app.use(express.favicon()); // nicer logging app.use(express.logger('dev')); // you will need to use cookieParser to expose cookies to req.cookies app.use(express.cookieParser()); // i18n init parses req for language headers, cookies, etc. app.use(i18n.init); // binding template helpers to request (Credits to https://github.com/enyo #12) app.use(function (req, res, next) { res.locals.__ = res.__ = function () { return i18n.__.apply(req, arguments); }; res.locals.__n = res.__n = function () { return i18n.__n.apply(req, arguments); }; next(); }); }); // serving homepage app.get('/', function (req, res) { res.send(res.__('Hello World')); }); // starting server if (!module.parent) { app.listen(3000); } This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ { "name": "express-example", "version": "0.0.0", "author": "Marcus Spiegel <marcus.spiegel@gmail.com>", "dependencies": { "express": "*", "i18n": "*" } }