How to use the react-i18next.setI18n function in react-i18next

To help you get started, we’ve selected a few react-i18next examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flow-typed / flow-typed / definitions / npm / react-i18next_v7.x.x / flow_v0.62.x-0.63.x / test_react-i18next_v7.x.x.js View on Github external
it("errors if passed a non-object", () => {
      // $ExpectError - i18n object should be passed to setI18n
      setI18n("string");
    });
  });
github flow-typed / flow-typed / definitions / npm / react-i18next_v7.x.x / flow_v0.53.x-0.61.x / test_react-i18next_v7.x.x.js View on Github external
setDefaults({ other: true });

// passing
getDefaults();
// $ExpectError - no arguments should be passed to getDefaults
getDefaults("string");

// passing
getI18n();
// $ExpectError - no arguments should be passed to getI18n
getI18n("string");

// passing
setI18n(i18n);
// $ExpectError - setI18n must be called with an object
setI18n("option");
github flow-typed / flow-typed / definitions / npm / react-i18next_v6.x.x / test_react-i18next_v6.x.x.js View on Github external
setDefaults("option");
// $ExpectError - other is not a valid option
setDefaults({ other: true });

// passing
getDefaults();
// $ExpectError - no arguments should be passed to getDefaults
getDefaults("string");

// passing
getI18n();
// $ExpectError - no arguments should be passed to getI18n
getI18n("string");

// passing
setI18n(i18n);
// $ExpectError - setI18n must be called with an object
setI18n("option");
github flow-typed / flow-typed / definitions / npm / react-i18next_v6.x.x / test_react-i18next_v6.x.x.js View on Github external
setDefaults({ other: true });

// passing
getDefaults();
// $ExpectError - no arguments should be passed to getDefaults
getDefaults("string");

// passing
getI18n();
// $ExpectError - no arguments should be passed to getI18n
getI18n("string");

// passing
setI18n(i18n);
// $ExpectError - setI18n must be called with an object
setI18n("option");
github flow-typed / flow-typed / definitions / npm / react-i18next_v7.x.x / flow_v0.53.x-0.61.x / test_react-i18next_v7.x.x.js View on Github external
setDefaults("option");
// $ExpectError - other is not a valid option
setDefaults({ other: true });

// passing
getDefaults();
// $ExpectError - no arguments should be passed to getDefaults
getDefaults("string");

// passing
getI18n();
// $ExpectError - no arguments should be passed to getI18n
getI18n("string");

// passing
setI18n(i18n);
// $ExpectError - setI18n must be called with an object
setI18n("option");
github Talend / ui / packages / components / src / translate.js View on Github external
import i18next, { createInstance } from 'i18next';
import { setI18n, getI18n } from 'react-i18next';

if (!getI18n()) {
	// eslint-disable-next-line no-console
	console.warn('@talend/react-components used without i18n host.');
	// https://github.com/i18next/i18next/issues/936#issuecomment-307550677
	setI18n(createInstance({}, () => {}));
}

export default function getDefaultT() {
	const i18n = getI18n();
	if (i18n) {
		return i18n.t.bind(getI18n());
	}
	return global.I18NEXT_T;
}

export function getCurrentLanguage() {
	if (i18next.language) {
		return i18next.language;
	}
	return 'en';
}
github Talend / ui / packages / datagrid / src / translate.js View on Github external
import { createInstance } from 'i18next';
import { setI18n, getI18n } from 'react-i18next';

export default function getDefaultT() {
	return getI18n().t.bind(getI18n());
}

if (!getI18n()) {
	// eslint-disable-next-line no-console
	console.warn('@talend/react-datagrid used without i18n host.');
	setI18n(createInstance({}, () => {}));
}
github Talend / ui / packages / stepper / src / translate.js View on Github external
import { createInstance } from 'i18next';
import { setI18n, getI18n } from 'react-i18next';

export default function getDefaultT() {
	return getI18n().t.bind(getI18n());
}

if (!getI18n()) {
	// eslint-disable-next-line no-console
	console.warn('@talend/react-stepper used without i18n host.');
	setI18n(createInstance({}, () => {}));
}
github Talend / ui / packages / forms / src / translate.js View on Github external
import { createInstance } from 'i18next';
import { setI18n, getI18n } from 'react-i18next';

// eslint-disable-next-line import/prefer-default-export
export default function getDefaultT() {
	return getI18n().t.bind(getI18n());
}

if (!getI18n()) {
	// eslint-disable-next-line no-console
	console.warn('@talend/react-forms used without i18n host.');
	setI18n(createInstance({}, () => {}));
}