2014-11-21 12:50:26 +09:00
|
|
|
// do this better:
|
|
|
|
setLanguage = function (language) {
|
2014-11-24 11:27:07 +09:00
|
|
|
// Session.set('i18nReady', false);
|
2014-11-21 13:19:15 +09:00
|
|
|
// console.log('i18n loading… '+language)
|
2014-11-21 12:50:26 +09:00
|
|
|
|
|
|
|
// moment
|
2014-11-21 13:19:15 +09:00
|
|
|
Session.set('momentReady', false);
|
|
|
|
// console.log('moment loading…')
|
2014-12-04 11:20:41 +09:00
|
|
|
if (language.toLowerCase() === "en") {
|
2014-11-21 13:19:15 +09:00
|
|
|
Session.set('momentReady', true);
|
2014-12-04 11:20:41 +09:00
|
|
|
} else {
|
|
|
|
$.getScript("//cdnjs.cloudflare.com/ajax/libs/moment.js/2.5.1/lang/" + language.toLowerCase() + ".js", function (result) {
|
|
|
|
moment.locale(language);
|
|
|
|
Session.set('momentReady', true);
|
|
|
|
Session.set('momentLocale', language);
|
|
|
|
// console.log('moment loaded!')
|
|
|
|
});
|
|
|
|
}
|
2014-11-21 12:50:26 +09:00
|
|
|
|
|
|
|
// TAPi18n
|
2014-11-24 11:27:07 +09:00
|
|
|
Session.set("TAPi18nReady", false);
|
2014-11-21 13:19:15 +09:00
|
|
|
// console.log('TAPi18n loading…')
|
2014-11-21 12:50:26 +09:00
|
|
|
TAPi18n.setLanguage(language)
|
|
|
|
.done(function () {
|
2014-11-24 11:27:07 +09:00
|
|
|
Session.set("TAPi18nReady", true);
|
2014-11-21 13:19:15 +09:00
|
|
|
// console.log('TAPi18n loaded!')
|
2014-11-21 12:50:26 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
// T9n
|
|
|
|
T9n.setLanguage(language);
|
|
|
|
}
|
|
|
|
|
2013-11-21 11:32:09 +09:00
|
|
|
i18n = {
|
2014-11-19 01:23:31 +08:00
|
|
|
t: function (str, options) {
|
|
|
|
if (Meteor.isServer) {
|
|
|
|
return TAPi18n.__(str, options, getSetting('language', 'en'));
|
|
|
|
} else {
|
|
|
|
return TAPi18n.__(str, options);
|
2013-11-21 11:32:09 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-11-19 01:23:31 +08:00
|
|
|
Meteor.startup(function () {
|
2014-11-20 14:56:29 +09:00
|
|
|
|
2014-11-21 13:19:15 +09:00
|
|
|
if (Meteor.isClient) {
|
|
|
|
|
|
|
|
// doesn't quite work yet
|
|
|
|
// Tracker.autorun(function (c) {
|
|
|
|
// console.log('momentReady',Session.get('momentReady'))
|
|
|
|
// console.log('i18nReady',Session.get('i18nReady'))
|
|
|
|
// var ready = Session.get('momentReady') && Session.get('i18nReady');
|
|
|
|
// if (ready) {
|
|
|
|
// Session.set('i18nReady', true);
|
|
|
|
// Session.set('locale', language);
|
|
|
|
// console.log('i18n ready! '+language)
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
|
2014-11-21 12:50:26 +09:00
|
|
|
setLanguage(getSetting('language', 'en'));
|
2014-11-21 13:19:15 +09:00
|
|
|
}
|
2014-11-20 14:56:29 +09:00
|
|
|
|
2014-11-19 01:23:31 +08:00
|
|
|
});
|