Skip to content

i18n Types

This file defines TypeScript types used for configuring and representing translations in the @sodacore/core i18n (internationalization) module. These types provide strong typing for plugin/service configuration and translation data structures.


Types

IConfig

Configuration options for the i18n plugin/service.

typescript
export type IConfig = {
	defaultLocale?: string,        // Optional: The default locale to use (e.g., 'en-GB').
	translationsPath?: string,     // Optional: Path to the directory containing translation files.
};
  • defaultLocale: Optional string specifying the default locale (e.g., 'en-GB'). Used when no preferred language is specified or available.

  • translationsPath: Optional string specifying the path to the directory containing translation files. Defaults to './translations' if not provided.


ITranslation

Type definition for a translation object.

typescript
export type ITranslation = {
	_lang: string,                // The language code (e.g., 'en').
	_code: string,                // The full locale code (e.g., 'en-GB').
	_country: string,             // The country code (e.g., 'GB').
	[key: string]: string,        // Key-value pairs for translation strings.
};
  • _lang: The language code (e.g., 'en').

  • _code: The full locale code (e.g., 'en-GB').

  • _country: The country code (e.g., 'GB').

  • [key: string]: string: Additional key-value pairs for translation strings, where each key is a translation key and the value is the localized string.


Notes

  • These types are intended for internal use by the Sodacore i18n plugin and service, but can be used in your application for type safety.
  • The ITranslation type allows for flexible and extensible translation objects, supporting any number of translation keys.

Released under the Apache-2.0 License.