infinity-forge
Version:
27 lines • 1.59 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.I18nProvider = I18nProvider;
exports.useI18n = useI18n;
var jsx_runtime_1 = require("react/jsx-runtime");
var react_1 = require("react");
var ui_1 = require("../../../ui/index.js");
var i18nContext = (0, react_1.createContext)({
languages: [],
});
function I18nProvider(_a) {
var _b, _c, _d, _e;
var children = _a.children;
var admin = (0, ui_1.useDynamicSection)({
refSection: 'configuration_admin',
isGlobal: true,
});
var i18nIsActive = !!((_b = admin.jsonContent) === null || _b === void 0 ? void 0 : _b.i18n);
var jsonContent = (0, ui_1.useDynamicSection)({ refSection: 'i18n', isGlobal: true }).jsonContent;
var languages = (jsonContent === null || jsonContent === void 0 ? void 0 : jsonContent.languages) || ((_c = jsonContent === null || jsonContent === void 0 ? void 0 : jsonContent.jsonContent) === null || _c === void 0 ? void 0 : _c.languages);
var mainLanguage = ((_d = languages === null || languages === void 0 ? void 0 : languages.find(function (language) { return language.main; })) === null || _d === void 0 ? void 0 : _d.symbol) || ((_e = languages === null || languages === void 0 ? void 0 : languages[0]) === null || _e === void 0 ? void 0 : _e.symbol);
return (0, jsx_runtime_1.jsx)(i18nContext.Provider, { value: { i18nIsActive: i18nIsActive, mainLanguage: mainLanguage, languages: languages }, children: children });
}
function useI18n() {
return (0, react_1.useContext)(i18nContext);
}
//# sourceMappingURL=context.js.map