UNPKG

@premieroctet/next-admin

Version:

Next-Admin provides a customizable and turnkey admin dashboard for applications built with Next.js and powered by the Prisma ORM. It aims to simplify the development process by providing a turnkey admin system that can be easily integrated into your proje

24 lines (23 loc) 781 B
"use client"; import { jsx } from "react/jsx-runtime"; import external_react_default, { createContext } from "react"; const I18nContext = /*#__PURE__*/ createContext({ t: ()=>"" }); const I18nProvider = ({ translations, children })=>{ const t = (key, options, fallback)=>{ let translation = translations[key]; if (options && translation) Object.entries(options).forEach(([key, value])=>{ translation = translation.replace(`{{${key}}}`, value); }); return translation ?? fallback ?? key; }; return /*#__PURE__*/ jsx(I18nContext.Provider, { value: { t }, children: children }); }; const useI18n = ()=>external_react_default.useContext(I18nContext); export { I18nProvider, useI18n };