Skip to content

Commit

Permalink
Allow switching language using lang url param
Browse files Browse the repository at this point in the history
Currently if a language is selected and i18n messages
are missing the i18n code will be displayed instead
  • Loading branch information
addshore committed Apr 27, 2016
1 parent 87bf886 commit bb61b81
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion js/app/Messages.js
Expand Up @@ -3,4 +3,19 @@
var Polyglot = require( 'node-polyglot' ),
i18n = require( '../i18n.json' );

module.exports = new Polyglot( { phrases: i18n[ 'de' ] } );
var getParam = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;

for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');

if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : sParameterName[1];
}
}
};

module.exports = new Polyglot( { phrases: i18n[ getParam('lang') ] } );

0 comments on commit bb61b81

Please sign in to comment.