UNPKG

infinity-forge

Version:
26 lines 910 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useI18nText = useI18nText; exports.useI18nData = useI18nData; var router_1 = require("next/router"); var react_1 = require("react"); function useI18nText() { var _a = (0, router_1.useRouter)().locale, locale = _a === void 0 ? 'pt-BR' : _a; var formatText = (0, react_1.useCallback)(function (_a) { var i18n = _a.i18n, i18nKey = _a.i18nKey; if (!i18n || !i18n[locale] || !i18n[locale][i18nKey]) { return 'Translate Not Found'; } return i18n[locale][i18nKey]; }, [locale]); return { formatText: formatText }; } function useI18nData(_a) { var i18n = _a.i18n; var _b = (0, router_1.useRouter)().locale, locale = _b === void 0 ? 'pt-BR' : _b; if (!i18n || !i18n[locale]) { return {}; } return i18n[locale]; } //# sourceMappingURL=index.js.map