Created
April 3, 2014 01:52
-
-
Save 3dd13/9946929 to your computer and use it in GitHub Desktop.
Revisions
-
3dd13 created this gist
Apr 3, 2014 .There are no files selected for viewing
This file contains hidden or 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,7 @@ <!-- app/views/layouts/application.html.ejs --> <!-- generate a link with to switch locale --> <ul> <li><%- linkTo(i18n.getText("nav.links.switch_to_english"), {locale: "en-us"}) %></li> <li><%- linkTo(i18n.getText("nav.links.switch_to_chinese"), {locale: "zh-tw"}) %></li> </ul> This file contains hidden or 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,10 @@ // app/controllers/application.js // decide the locale to be used in view, inside application controller before filter var Application = function () { this.before(function() { this.i18n.setLocale(this.params.locale); }); }; exports.Application = Application; This file contains hidden or 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,5 @@ // config/locales/en-us.json { "main.header.courses": "courses", } This file contains hidden or 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,11 @@ // config/environment.js // set default locale when no locale is provided var config = { generatedByVersion: '0.12.7', i18n: { defaultLocale: 'en-us' } } module.exports = config; This file contains hidden or 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,7 @@ <!-- app/views/main/index.html.ejs --> <!-- show translated text --> <h1><%= i18n.getText('main.header.courses') %></h1> <!-- generate a link with current locale --> <%- linkTo(i18n.getText("faq.question.when"), {controller: "about", action: "index", anchor: "faq", locale: i18n.getLocale()}) %> This file contains hidden or 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,5 @@ // config/locales/zh-tw.json { "main.header.courses": "課程", }