import { getTranslation } from "../@intlayer/core/dist/esm/interpreter/getTranslation.mjs";
import { getServerContext } from "./serverContext.mjs";
import { IntlayerServerContext } from "./IntlayerServerProvider.mjs";

//#region ../react-intlayer/dist/esm/server/t.mjs
/**
* On the server side, hook to get the translation content based on the locale
*
* If not locale found, it will return the content related to the default locale.
*
* Return either the content editor, or the content itself depending on the configuration.
*
* Usage:
*
* ```ts
* const content = t<string>({
*   en: 'Hello',
*   fr: 'Bonjour',
* }, 'fr');
* // 'Bonjour'
* ```
*
* Using TypeScript:
* - this function will require each locale to be defined if defined in the project configuration.
* - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.
*/
const t = (multilangContent, locale) => {
	const currentLocale = getServerContext(IntlayerServerContext);
	return getTranslation(multilangContent, locale ?? currentLocale);
};

//#endregion
export { t };
//# sourceMappingURL=t.mjs.map