mirror of
https://github.com/vale981/Vulcan
synced 2025-03-09 12:16:37 -04:00
62 lines
1.6 KiB
JavaScript
62 lines
1.6 KiB
JavaScript
// do this better:
|
|
setLanguage = function (language) {
|
|
// Session.set('i18nReady', false);
|
|
// console.log('i18n loading… '+language)
|
|
|
|
// moment
|
|
Session.set('momentReady', false);
|
|
// console.log('moment loading…')
|
|
if (language.toLowerCase() === "en") {
|
|
Session.set('momentReady', true);
|
|
} 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!')
|
|
});
|
|
}
|
|
|
|
// TAPi18n
|
|
Session.set("TAPi18nReady", false);
|
|
// console.log('TAPi18n loading…')
|
|
TAPi18n.setLanguage(language)
|
|
.done(function () {
|
|
Session.set("TAPi18nReady", true);
|
|
// console.log('TAPi18n loaded!')
|
|
});
|
|
|
|
// T9n
|
|
T9n.setLanguage(language);
|
|
}
|
|
|
|
i18n = {
|
|
t: function (str, options) {
|
|
if (Meteor.isServer) {
|
|
return TAPi18n.__(str, options, getSetting('language', 'en'));
|
|
} else {
|
|
return TAPi18n.__(str, options);
|
|
}
|
|
}
|
|
};
|
|
|
|
Meteor.startup(function () {
|
|
|
|
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)
|
|
// }
|
|
// });
|
|
|
|
setLanguage(getSetting('language', 'en'));
|
|
}
|
|
|
|
});
|