Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Modified README and added the section which describes the possibility…

… to change the language parameter. This is release v0.3.4
  • Loading branch information...
commit d7b19c4674bc2d57dc7760faea1905d45cd85b9c 1 parent 3657289
@akoenig authored
View
20 README.md
@@ -22,7 +22,7 @@ Using lingua comes down with four simple steps:
...
// Express app configuration code and lingua init.
- app.configure(function(){
+ app.configure(function() {
...
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
@@ -109,6 +109,24 @@ Using lingua comes down with four simple steps:
<a href="?language=en-US">en-US</a>
```
+You can configure lingua in order to change the name of this parameter.
+
+```javascript
+
+// Express app configuration code and lingua init.
+app.configure(function() {
+ ...
+
+ // Lingua configuration
+ app.use(lingua(app, {
+ defaultLocale: 'en',
+ path: __dirname + '/i18n',
+ storageKey: 'lang' // http://domain.tld/?lang=de
+ }));
+
+ ...
+});
+```
## Example Application
View
47 diff
@@ -0,0 +1,47 @@
+lingua.js
+@@ -24,7 +24,7 @@ module.exports = function (app, options) {
+24 24
+ // The lingua configuration object.
+25 25
+ //
+26 26
+ config.storage = {
+27
+- key: 'language'
+27
++ key: options.storageKey || 'language'
+28 28
+ };
+29 29
+
+30 30
+ config.resources = {
+
+
+trainee.js
+
+@@ -111,10 +111,9 @@ module.exports = (function() {
+111 111
+ // Based on connect-i18n: https://github.com/masylum/connect-i18n/blob/master/lib/connect-i18n.js
+112 112
+ //
+113 113
+ Trainee.prototype.determineLocales = function(req, res) {
+114
+- var querystring = url.parse(req.url, true),
+115
+- cookies = new Cookies(req, res),
+114
++ var cookies = new Cookies(req, res),
+116 115
+ headers = req.headers,
+117
+- query = querystring.query[this.configuration.storage.key],
+ 116
++ query = req.query[this.configuration.storage.key],
+118 117
+ cookie = cookies.get(this.configuration.storage.key),
+119 118
+ locales = [], // The determined locales which the user has configured.
+120 119
+ locale = (query || cookie);
View
2  example/app.js
@@ -5,7 +5,7 @@
* Licensed under the MIT:
* http://www.opensource.org/licenses/mit-license.php
*
- * Copyright (c) 2012, André König (andre.koenig -[at]- gmail [*dot*] com)
+ * Copyright (c) 2013, André König (andre.koenig -[at]- gmail [*dot*] com)
*
*/
/**
View
2  lib/guru.js
@@ -5,7 +5,7 @@
* Licensed under the MIT:
* http://www.opensource.org/licenses/mit-license.php
*
- * Copyright (c) 2012, André König (andre.koenig -[at]- gmail [*dot*] com)
+ * Copyright (c) 2013, André König (andre.koenig -[at]- gmail [*dot*] com)
*
*/
View
2  lib/languagetags.js
@@ -5,7 +5,7 @@
* Licensed under the MIT:
* http://www.opensource.org/licenses/mit-license.php
*
- * Copyright (c) 2012, André König (andre.koenig -[at]- gmail [*dot*] com)
+ * Copyright (c) 2013, André König (andre.koenig -[at]- gmail [*dot*] com)
*
*/
View
2  lib/lingua.js
@@ -5,7 +5,7 @@
* Licensed under the MIT:
* http://www.opensource.org/licenses/mit-license.php
*
- * Copyright (c) 2012, André König (andre.koenig -[at]- gmail [*dot*] com)
+ * Copyright (c) 2013, André König (andre.koenig -[at]- gmail [*dot*] com)
*
*/
var Guru = require('./guru'),
View
2  lib/trainee.js
@@ -5,7 +5,7 @@
* Licensed under the MIT:
* http://www.opensource.org/licenses/mit-license.php
*
- * Copyright (c) 2012, André König (andre.koenig -[at]- gmail [*dot*] com)
+ * Copyright (c) 2013, André König (andre.koenig -[at]- gmail [*dot*] com)
*
*/
var url = require('url'),
View
2  package.json
@@ -1,7 +1,7 @@
{
"name": "lingua",
"description": "An i18n middleware for the Express.js framework.",
- "version": "0.3.3",
+ "version": "0.3.4",
"repository": {
"type": "git",
"url": "git://github.com/akoenig/express-lingua.git"
Please sign in to comment.
Something went wrong with that request. Please try again.