Skip to content

Commit

Permalink
feat(translations): add es and hu translations
Browse files Browse the repository at this point in the history
  • Loading branch information
MHA committed Jul 20, 2020
1 parent 3ca6c02 commit 3b022c8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/localize/localize.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import * as en from './languages/en.json';
import * as es from './languages/es.json';
import * as hu from './languages/hu.json';
import * as nl from './languages/nl.json';

var languages = {
const languages = {
en: en,
es: es,
hu: hu,
nl: nl,
};

export function localize(string: string, search: string = '', replace: string = '') {
export function localize(string: string, search: string = '', replace: string = ''): string {
const section = string.split('.')[0];
const key = string.split('.')[1];

const lang = (localStorage.getItem('selectedLanguage') || 'en').replace(/['"]+/g, '').replace('-', '_');

var tranlated: string;
let tranlated: string;

try {
tranlated = languages[lang][section][key];
Expand Down

0 comments on commit 3b022c8

Please # to comment.