Files
habitica/website/client/libs/i18n.js
Matteo Pagliazzi d9d7c69432 Client: async resources, make store reusable, move plugins and add getTaskFor getter (#8575)
Add library to manage async resource
Make Store reusable for easier testing
Move plugin to libs
Add getTaskFor getter with tests
2017-03-18 18:33:08 +01:00

23 lines
644 B
JavaScript

// Vue plugin to globally expose a '$t' method that calls common/i18n.t.
// Can be anywhere inside vue as 'this.$t' or '$t' in templates.
import i18n from 'common/script/i18n';
// Load all english translations
// TODO it's a workaround until proper translation loading works
const context = require.context('common/locales/en', true, /\.(json)$/);
const translations = {};
context.keys().forEach(filename => {
Object.assign(translations, context(filename));
});
i18n.strings = translations;
export default {
install (Vue) {
Vue.prototype.$t = function translateString () {
return i18n.t.apply(null, arguments);
};
},
};