Configuration options for TranslationContainer model instances.

This interface defines the configuration structure for translation container models, which manage multiple translation namespaces and coordinate global locale switching. Containers serve as the central orchestration point for internationalization in KOS applications.

Example: Basic Container Configuration

// Multi-namespace application translations
const containerOptions: TranslationContainerOptions = {
lang: 'es',
defaultNamespace: 'common',
descriptor: {
namespaces: {
'common': {
basePath: '/assets/locales',
locales: {
'en': { file: 'en/common.json', defaultLocale: 'en' },
'es': { file: 'es/common.json', defaultLocale: 'en' },
'fr': { file: 'fr/common.json', defaultLocale: 'en' }
}
},
'dashboard': {
basePath: '/assets/locales',
locales: {
'en': { file: 'en/dashboard.json', defaultLocale: 'en' },
'es': { file: 'es/dashboard.json', defaultLocale: 'en' },
'fr': { file: 'fr/dashboard.json', defaultLocale: 'en' }
}
}
}
}
};

const appTranslations = TranslationContainer.instance('app-i18n')
.options(containerOptions)
.build();

Example: CDN-Based Translation Loading

// Custom resolver for CDN-hosted translations
const cdnResolver = function(
namespace: string,
locale: string
): string {
return `https://cdn.example.com/translations/${namespace}/${locale}.json`;
};

const cdnOptions: TranslationContainerOptions = {
lang: 'ja',
resolver: cdnResolver,
descriptor: {
namespaces: {
'device-control': {
basePath: '', // Ignored with custom resolver
locales: {
'ja': { file: '', defaultLocale: 'en' },
'en': { file: '', defaultLocale: 'en' }
}
}
}
}
};

Example: Development Environment Setup

// Hot-reload friendly configuration for development
const devOptions: TranslationContainerOptions = {
lang: 'en',
rootUrl: '/dev-translations',
descriptor: {
namespaces: {
'ui': {
basePath: '/ui-translations',
locales: {
'en': { file: 'en/ui.json', defaultLocale: 'en' },
'es': { file: 'es/ui.json', defaultLocale: 'en' }
}
},
'forms': {
basePath: '/form-translations',
locales: {
'en': { file: 'en/forms.json', defaultLocale: 'en' },
'es': { file: 'es/forms.json', defaultLocale: 'en' }
}
}
}
}
};
interface TranslationContainerOptions {
    lang: string;
    descriptor: Localization;
    defaultNamespace?: string;
    rootUrl?: string;
    descriptorUrl?: string;
    resolver?: ((this, namespace, locale) => string);
}

Properties

lang: string

Current application-wide locale setting. Applied to all child translation models when they are created or updated.

Example

"en" - English

Example

"es" - Spanish

Example

"pt-BR" - Brazilian Portuguese
descriptor: Localization

Comprehensive locale and namespace descriptor defining the complete translation structure for the application.

defaultNamespace?: string

Optional default namespace for application-wide common translations. When specified, provides easy access to shared UI elements and messages.

Example

"common"

Example

"shared"

Example

"ui-elements"
rootUrl?: string

Optional base URL for all translation file loading. Applied as prefix to all translation resource paths.

Example

"/assets/locales"

Example

"https://cdn.example.com/app-translations"

Example

"/tenant-specific/translations"
descriptorUrl?: string

Optional URL for loading translation descriptor dynamically. Enables runtime configuration of translation structure.

Example

"/api/translations/descriptor"

Example

"https://config.example.com/translation-manifest.json"
resolver?: ((this, namespace, locale) => string)

Optional custom resolver for translation file path construction. Overrides default path resolution logic for all namespaces.

Type declaration

    • (this, namespace, locale): string
    • Parameters

      Returns string

Returns

Full path to translation resource