2017-03-18 17:33:08 +00:00
|
|
|
// 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';
|
2017-01-14 20:12:11 +00:00
|
|
|
|
|
|
|
|
// Load all english translations
|
|
|
|
|
// TODO it's a workaround until proper translation loading works
|
2017-03-18 17:33:08 +00:00
|
|
|
const context = require.context('common/locales/en', true, /\.(json)$/);
|
2017-01-14 20:12:11 +00:00
|
|
|
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);
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
};
|