lemmy/ui/src/i18next.ts

34 lines
686 B
TypeScript
Raw Normal View History

2019-08-09 01:58:04 +00:00
import * as i18n from 'i18next';
2019-08-09 05:09:36 +00:00
import { getLanguage } from './utils';
import { en } from './translations/en';
import { de } from './translations/de';
2019-08-07 19:12:53 +00:00
// https://github.com/nimbusec-oss/inferno-i18next/blob/master/tests/T.test.js#L66
2019-08-09 01:58:04 +00:00
// TODO don't forget to add moment locales for new languages.
const resources = {
2019-08-09 05:09:36 +00:00
en: en,
de: de,
}
function format(value: any, format: any, lng: any) {
if (format === 'uppercase') return value.toUpperCase();
return value;
}
2019-08-09 01:58:04 +00:00
i18n
.init({
2019-08-09 05:09:36 +00:00
debug: true,
// load: 'languageOnly',
// initImmediate: false,
lng: getLanguage(),
2019-08-09 01:58:04 +00:00
fallbackLng: 'en',
resources,
interpolation: {
2019-08-09 05:09:36 +00:00
format: format
}
});
2019-08-09 01:58:04 +00:00
export { i18n, resources };