ra-core
Version:
Core components of react-admin, a frontend Framework for building admin applications on top of REST services, using ES6, React
19 lines (14 loc) • 554 B
text/typescript
import { createContext } from 'react';
import { I18nProvider } from '../types';
import { substituteTokens } from './substituteTokens';
export type I18nContextProps = I18nProvider;
const defaultI18nProvider = {
translate: (key, options) =>
options?._
? substituteTokens(options._, options)
: substituteTokens(key, options),
changeLocale: () => Promise.resolve(),
getLocale: () => 'en',
};
export const I18nContext = createContext<I18nProvider>(defaultI18nProvider);
I18nContext.displayName = 'I18nContext';