UNPKG

@gasket/plugin-intl

Version:
29 lines (28 loc) 1.1 kB
/// <reference types="@gasket/plugin-https" /> /** * Preboot lifecycle hook - waits for all locale files to finish loading * before the server opens its port. * * InternalIntlManager.init() kicks off locale preloading asynchronously * (fire-and-forget) when the manager is first imported. Without this hook, * requests that arrive before preloading completes receive an empty messages * object and render i18n keys instead of translated strings. * * LocaleHandler.load() returns the already in-flight promise from * promisesRegister (debounced), so this does not trigger extra I/O. * @type {import('@gasket/core').HookHandler<'preboot'>} */ Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "default", { enumerable: true, get: function() { return preboot; } }); async function preboot(gasket) { if (gasket.config.intl?.experimentalImportAttributes) { const intlMgr = await gasket.actions.getIntlManager(); await Promise.all(intlMgr.locales.map((locale)=>intlMgr.handleLocale(locale).load())); } }