Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("errors if passed a non-object", () => {
// $ExpectError - i18n object should be passed to setI18n
setI18n("string");
});
});
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");
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");
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");
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");
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';
}
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({}, () => {}));
}
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({}, () => {}));
}
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({}, () => {}));
}
it("passes when called with an object", () => {
setI18n(i18n);
});