mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 23:27:26 +01:00
fix(language): load locale during build of app.vue
This commit is contained in:
@@ -406,7 +406,10 @@ export default {
|
|||||||
this.$store.state.isUserLoaded = true;
|
this.$store.state.isUserLoaded = true;
|
||||||
Analytics.setUser();
|
Analytics.setUser();
|
||||||
Analytics.updateUser();
|
Analytics.updateUser();
|
||||||
|
return axios.get('/api/v4/i18n/browser-script', { language: this.user.preferences.language });
|
||||||
|
}).then(() => {
|
||||||
|
const i18nData = window && window['habitica-i18n'];
|
||||||
|
this.$loadLocale(i18nData);
|
||||||
this.hideLoadingScreen();
|
this.hideLoadingScreen();
|
||||||
|
|
||||||
// Adjust the timezone offset
|
// Adjust the timezone offset
|
||||||
|
|||||||
@@ -4,9 +4,7 @@
|
|||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import i18n from '@/../../common/script/i18n';
|
import i18n from '@/../../common/script/i18n';
|
||||||
|
|
||||||
export default {
|
function loadLocale (i18nData) {
|
||||||
install (Vue, { i18nData }) {
|
|
||||||
if (i18nData) {
|
|
||||||
// Load i18n strings
|
// Load i18n strings
|
||||||
i18n.strings = i18nData.strings;
|
i18n.strings = i18nData.strings;
|
||||||
|
|
||||||
@@ -27,6 +25,12 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
install (Vue, { i18nData }) {
|
||||||
|
if (i18nData) loadLocale(i18nData);
|
||||||
|
|
||||||
|
Vue.prototype.$loadLocale = loadLocale;
|
||||||
|
|
||||||
Vue.prototype.$t = function translateString (...args) {
|
Vue.prototype.$t = function translateString (...args) {
|
||||||
return i18n.t.apply(null, [...args]);
|
return i18n.t.apply(null, [...args]);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user