0.2.0 • Published 8 years ago

tg-i18n v0.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

tg-i18n

Internal tool to use translations in React that are loaded from our Django backend

Example init:

// i18n.js
import makeI18n, {setConfig} from 'tg-i18n';

const LANGUAGE_CODE = 'en';
const LOCALE_DATA = {
    '': {
        'domain': 'djangojs',
        // locale header
    },
    
    'en': {
        // translation strings
    },
}; 

setConfig('languageCode', LANGUAGE_CODE);
setConfig('localeData', LOCALE_DATA || {});

const i18n = makeI18n();

export const gettext = i18n.gettext;
export const pgettext = i18n.pgettext;
export const ngettext = i18n.ngettext;
export const npgettext = i18n.npgettext;
export const interpolate = i18n.interpolate;

export {setConfig} from 'tg-i18n';
export default i18n;

Using:

import i18n, {gettext} from './i18n';

i18n.setActiveLang('en');

console.log(gettext('Test string');
0.2.0

8 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago