(id: string, defaultMessage: string, values?: Record<string, unknown>)
| 199 | } |
| 200 | |
| 201 | export const t: TFunction = (id: string, defaultMessage: string, values?: Record<string, unknown>) => { |
| 202 | initDefaultI18nInstance(); |
| 203 | if (!tFunc) { |
| 204 | if (process.env.NODE_ENV !== 'test') { |
| 205 | console.warn( |
| 206 | 't() was called before i18n was initialized. This is probably caused by calling t() in the root module scope, instead of lazily on render' |
| 207 | ); |
| 208 | } |
| 209 | |
| 210 | if (process.env.NODE_ENV === 'development') { |
| 211 | throw new Error('t() was called before i18n was initialized'); |
| 212 | } |
| 213 | |
| 214 | tFunc = getI18nInstance().t; |
| 215 | } |
| 216 | |
| 217 | return tFunc(id, defaultMessage, values); |
| 218 | }; |
| 219 | |
| 220 | export function Trans(props: TransProps): React.ReactElement { |
| 221 | initDefaultI18nInstance(); |
no test coverage detected