mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
New Client: english translations and misc fixes (#8410)
* misc fixes and add english translations * add tests
This commit is contained in:
22
website/client/plugins/i18n.js
Normal file
22
website/client/plugins/i18n.js
Normal file
@@ -0,0 +1,22 @@
|
||||
// Plugin to expose globally a '$t' method that calls common/i18n.t.
|
||||
// Can be used 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);
|
||||
};
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user