How to make the meteor application support multiple languages ? for example :Chinese,English.
The first,I try to use the Handlebars.registerHelper and Session ,but I'm failed.
The test.js code :
Handlebars.registerHelper('language',function(arg){ var nalization = Session.get('nalization'); console.log(nalization); var language = Session.get("language")[nalization]; if (!language){ console.log("nalization"+nalization+" is undefined"); return ""; } console.log(arg); return language[arg] ? language[arg] : "undefined"; }); Template.hello.created = function(){ Session.set('nalization','cn'); } Deps.autorun(function (c) { Session.set("language",{ cn : { hello: "你好", language: "Language" }, en : { hello: "Hello", language: "语言" } }); c.stop(); }); Template.hello.events = { "click #language_cn":function(){ Session.get("nalization") !== "cn" ? Session.set("nalization","cn") : 1=1; }, "click #language_en":function(){ Session.set("nalization","en"); console.log(); } }
The test.html code :
<body>
{{> hello}}
</body>
<template name="hello">
<h1>{{#language "hello"}}{{/language}}</h1>
<label>{{#language "language"}}{{/language}}</label>
<button id="language_cn">中文</button>
<button id="language_en">English</button>
</template>
changed the value 'nalization' in Seesion by click events,but the value is not change in registerHeloer .nothing happen on html.
Any idea about the language globalization ? Thanks.