i18n Resource Loader (i18n/resourceLoaders.ts)

fastgpt · packages/web/i18n/resourceLoaders.ts · typescript · Apache-2.0
ui, infra, lang:typescript, tag:knn-classified, tag:resource-loading, tag:retry-logic, tag:web

TypeScript module for loading and managing internationalization language bundles with retry logic and status tracking. Reuse for multi-language web application localization.

// Source: https://github.com/labring/fastgpt | License: Apache-2.0 | Copyright 2023 Sealos
// Provided via justclaw.it.com; keep this notice with the code.
import type { I18nNsType } from './i18next';
import type { localeType } from '@fastgpt/global/common/i18n/type';
import { generatedLoaders, generatedLanguageBundles } from './resourceLoaders.generated';
import { I18N_NAMESPACES } from './constants';

export type ResourceStatus = 'pending' | 'loaded' | 'failed';
type LocaleResource = Record<string, string | Record<string, unknown>>;
type LanguageBundle = Record<I18nNsType[number], LocaleResource>;

const resourceStatus = new Map<string, ResourceStatus>();
const resourceErrors = new Map<string, unknown>();
const pendingLanguageBundles = new Map<localeType, Promise<LanguageBundle>>();
con

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key