Skip to content

i18n Package Entry Point (index.ts)

This file serves as the main entry point for the @sodacore/core i18n (internationalization) package. It re-exports the primary plugin, service, provider, response transformer, helper constants, and types, making them available for import from a single location. The default export is the I18nPlugin for easy integration with Sodacore applications.


Features

  • Centralized Exports: Provides all i18n-related services, providers, helpers, transformers, and types for easy import.
  • Default Plugin Export: Exports I18nPlugin as the default, enabling quick registration with the Sodacore application.
  • Helper Constants: Exports constants and helpers for use in i18n logic and configuration.
  • Response Transformation: Exports a response transformer for automatic translation of HTTP responses.
  • Type Exports: Exports TypeScript types for configuration and translation objects.

Usage

Import i18n features directly from the package root:

typescript
import I18nPlugin, {
	I18nProvider,
	I18nService,
	TranslateTransform,
	I18nHelper,
	type IConfig,
	type ITranslation,
} from '@sodacore/core/i18n';

Register the plugin with your Sodacore application:

typescript
import I18nPlugin from '@sodacore/core/i18n';
app.register(I18nPlugin);

API

Default Export

  • I18nPlugin The main plugin class for integrating i18n functionality with the Sodacore application.

Named Exports

  • I18nHelper: Helper constants and utilities for i18n.

  • I18nProvider: Provides translation utilities and auto-translation features.

  • I18nService: Handles loading and managing translation files and language codes.

  • TranslateTransform: A response transformer that automatically translates HTTP responses based on the request's Accept-Language header.

Type Exports

  • IConfig: Type for i18n configuration options.

  • ITranslation: Type for translation objects.


Notes

  • This file is intended to be the single import point for all i18n features in the Sodacore ecosystem.
  • All exports are organized for clarity and ease of use, supporting both application and library development.
  • TypeScript users benefit from strong typing and IntelliSense support for all exported features.

Released under the Apache-2.0 License.