2017-04-15 15:07:31 +00:00
|
|
|
import Jed from 'jed';
|
2017-04-21 08:16:05 +00:00
|
|
|
import { de } from './de/app';
|
|
|
|
import { es } from './es/app';
|
|
|
|
import { en } from './en/app';
|
2017-04-15 15:07:31 +00:00
|
|
|
|
|
|
|
const locales = {
|
|
|
|
de,
|
|
|
|
es,
|
|
|
|
en,
|
|
|
|
};
|
|
|
|
|
2017-04-18 15:29:22 +00:00
|
|
|
const lang = document.querySelector('html').getAttribute('lang') || 'en';
|
2017-04-26 16:03:06 +00:00
|
|
|
const locale = new Jed(locales[lang]);
|
|
|
|
const gettext = locale.gettext.bind(locale);
|
|
|
|
const ngettext = locale.ngettext.bind(locale);
|
2017-04-28 09:49:28 +00:00
|
|
|
const pgettext = (context, key) => {
|
|
|
|
const joinedKey = [context, key].join('|');
|
|
|
|
return gettext(joinedKey).split('|').pop();
|
|
|
|
};
|
2017-04-15 15:07:31 +00:00
|
|
|
|
|
|
|
export { lang };
|
2017-04-26 16:03:06 +00:00
|
|
|
export { gettext as __ };
|
|
|
|
export { ngettext as n__ };
|
|
|
|
export { pgettext as s__ };
|
|
|
|
export default locale;
|