Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
});
};
const useMock = [k => k, {}];
useMock.t = k => k;
useMock.i18n = {};
module.exports = {
// this mock makes sure any components using the translate HoC receive the t function as a prop
withTranslation: () => Component => props => k} {...props} />,
Trans: ({ children }) => renderNodes(children),
Translation: ({ children }) => children(k => k, { i18n: {} }),
useTranslation: () => useMock,
// mock if needed
I18nextProvider: reactI18next.I18nextProvider,
initReactI18next: reactI18next.initReactI18next,
setDefaults: reactI18next.setDefaults,
getDefaults: reactI18next.getDefaults,
setI18n: reactI18next.setI18n,
getI18n: reactI18next.getI18n,
};
*
* License: MIT
*/
const React = require("react");
const reactI18next = require("react-i18next");
module.exports = {
// this mock makes sure any components using the translate HoC receive the t function as a prop
translate: () => Component => props => k} {...props} />,
Trans: ({ children }) => children,
I18n: ({ children }) => children(k => k, { i18n: {} }),
// mock if needed
Interpolate: reactI18next.Interpolate,
I18nextProvider: reactI18next.I18nextProvider,
loadNamespaces: reactI18next.loadNamespaces,
reactI18nextModule: reactI18next.reactI18nextModule,
setDefaults: reactI18next.setDefaults,
getDefaults: reactI18next.getDefaults,
setI18n: reactI18next.setI18n,
getI18n: reactI18next.getI18n
};
const useMock = [(k) => k, {}]
useMock.t = (k) => k
useMock.i18n = { language: 'en' }
module.exports = {
// this mock makes sure any components using the translate HoC receive the t function as a prop
withTranslation: () => (Component) => (props) => (
k} i18n={{ language: 'en' }} {...props} />
),
Trans: ({ children }) => renderNodes(children),
Translation: ({ children }) => children((k) => k, { i18n: {} }),
useTranslation: () => useMock,
// mock if needed
I18nextProvider: reactI18next.I18nextProvider,
initReactI18next: reactI18next.initReactI18next,
setDefaults: reactI18next.setDefaults,
getDefaults: reactI18next.getDefaults,
setI18n: reactI18next.setI18n,
getI18n: reactI18next.getI18n,
}
const useMock = [(k) => k, {}]
useMock.t = (k) => k
useMock.i18n = { language: 'en' }
module.exports = {
// this mock makes sure any components using the translate HoC receive the t function as a prop
withTranslation: () => (Component) => (props) => (
k} i18n={{ language: 'en' }} {...props} />
),
Trans: ({ children }) => renderNodes(children),
Translation: ({ children }) => children((k) => k, { i18n: {} }),
useTranslation: () => useMock,
// mock if needed
I18nextProvider: reactI18next.I18nextProvider,
initReactI18next: reactI18next.initReactI18next,
setDefaults: reactI18next.setDefaults,
getDefaults: reactI18next.getDefaults,
setI18n: reactI18next.setI18n,
getI18n: reactI18next.getI18n,
}
return Object.keys(child).reduce(
(str, childKey) => `${str}${child[childKey]}`,
''
)
}
return child
})
}
module.exports = {
// this mock makes sure any components using the translate HoC receive the t function as a prop
getDefaults: reactI18next.getDefaults,
getI18n: reactI18next.getI18n,
I18n: ({ children }) => children(k => k, { i18n: {} }),
I18nextProvider: reactI18next.I18nextProvider,
Interpolate: reactI18next.Interpolate,
loadNamespaces: reactI18next.loadNamespaces,
reactI18nextModule: reactI18next.reactI18nextModule,
setDefaults: reactI18next.setDefaults,
setI18n: reactI18next.setI18n,
Trans: ({ children }) => renderNodes(children),
translate: () => Component => props => (
k}
i18n={{
changeLanguage: l => l,
language: 'en-US',
languages: ['en-US', 'pt'],
}}
{...props}
/>