feat(translations): new translation system

This commit is contained in:
David Ralph
2021-09-10 16:38:53 +01:00
parent 941c168486
commit b0eeff1bf8
63 changed files with 651 additions and 593 deletions

View File

@@ -1,3 +1,4 @@
import variables from 'modules/variables';
import { toast } from 'react-toastify';
export function saveFile(data, filename = 'file') {
@@ -28,12 +29,14 @@ export function exportSettings() {
}
export function importSettings(e) {
const getMessage = (languagecode, text) => variables.language.getMessage(languagecode, text);
const languagecode = variables.languagecode;
const content = JSON.parse(e.target.result);
Object.keys(content).forEach((key) => {
localStorage.setItem(key, content[key]);
});
toast(window.language.toasts.imported);
toast(getMessage(languagecode, 'toats.imported'));
window.stats.postEvent('tab', 'Settings imported');
}

6
src/modules/variables.js Normal file
View File

@@ -0,0 +1,6 @@
const variables = {
language: {},
languagecode: ''
};
export default variables;