UNPKG

@refinedev/core

Version:

refine is a React-based framework for building internal tools, rapidly. It ships with Ant Design System, an enterprise-level UI toolkit.

21 lines (16 loc) 465 B
import type { useTranslate } from "@hooks/i18n"; export const safeTranslate = ( translate: ReturnType<typeof useTranslate>, key: string, defaultMessage?: string, options?: any, ) => { const translated = options ? translate(key, options, defaultMessage) : translate(key, defaultMessage); const fallback = defaultMessage ?? key; if (translated === key || typeof translated === "undefined") { return fallback; } return translated; };