Skip to content

Commit

Permalink
feat(translations): adds translations support
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahu authored and adrianschmidt committed Sep 10, 2019
1 parent fe31311 commit ab396fc
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/global/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import config from './config';
import iconCache from './icon-cache';
import translations from './translations';

declare var Context: any;

Context.config = config;
Context.iconCache = iconCache;
Context.translations = translations;
18 changes: 18 additions & 0 deletions src/global/translations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import da from '../translations/da';
import en from '../translations/en';
import fi from '../translations/fi';
import no from '../translations/no';
import sv from '../translations/sv';

const allTranslations = { da: da, en: en, fi: fi, no: no, sv: sv };

export class Translations {
public get(key, language = 'en') {
return allTranslations[language][key];
}
}

const translations = new Translations();
export default (() => {
return translations;
})();
5 changes: 5 additions & 0 deletions src/translations/da.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
'date-picker.month.heading': 'Måned',
'date-picker.quarter.heading': 'Kvartal',
'date-picker.year.heading': 'År',
};
5 changes: 5 additions & 0 deletions src/translations/en.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
'date-picker.month.heading': 'Month',
'date-picker.quarter.heading': 'Quarter',
'date-picker.year.heading': 'Year',
};
5 changes: 5 additions & 0 deletions src/translations/fi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
'date-picker.month.heading': 'Kuukausi',
'date-picker.quarter.heading': 'Vuosineljännes',
'date-picker.year.heading': 'Vuosi',
};
5 changes: 5 additions & 0 deletions src/translations/no.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
'date-picker.month.heading': 'Måned',
'date-picker.quarter.heading': 'Kvartal',
'date-picker.year.heading': 'År',
};
5 changes: 5 additions & 0 deletions src/translations/sv.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
'date-picker.month.heading': 'Månad',
'date-picker.quarter.heading': 'Kvartal',
'date-picker.year.heading': 'År',
};

0 comments on commit ab396fc

Please sign in to comment.