Localization

Manage supported languages and localized content across the platform.

Bosca provides built-in support for managing localization through its LanguagesService. This service acts as the central registry for all supported languages in the system, ensuring consistent language handling across content, profiles, and interfaces.

Language Registry

The LanguagesService allows administrators to define which languages are active and available for use.

Key Features

  • Centralized Management: Add, edit, and remove supported languages globally.
  • Standardized Tags: Uses standard language tags (e.g., en, es, fr-CA) to ensure compatibility with browsers and external tools.
  • Metadata Support: Store additional language-specific attributes via JSON metadata.

Data Model

Each supported language is defined by the Language model:

data class Language(
    val tag: String,      // IETF BCP 47 language tag (e.g., "en-US")
    val name: String,     // English name (e.g., "English (United States)")
    val localName: String,// Native name (e.g., "English (United States)")
    val attributes: JsonElement? // Custom configuration
)

Service API

Developers can interact with the language registry programmatically via the LanguagesService interface.

interface LanguagesService : Service {
    // Retrieve all supported languages
    suspend fun getAll(): List<Language>

    // Get a specific language by tag
    suspend fun get(tag: String): Language?

    // Register a new supported language
    suspend fun add(language: Language)

    // Update an existing language definition
    suspend fun edit(language: Language)

    // Remove a language support
    suspend fun delete(tag: String)
}

Integration

This registry is used by other components to:

  • Validate content creation requests.
  • Filter search results by language.
  • Serve correct localized assets to users.