Skip to content

Conversation

@rahu1ramesh
Copy link
Contributor

@rahu1ramesh rahu1ramesh commented Apr 21, 2025

JIRA -> BN-41

This PR adds comprehensive internationalization (i18n) functionality to the Bahmni Clinical Frontend application, enabling multi-language support with a robust translation management system.

Key Features

  • Dual-Source Translation Strategy: Fetches translations from both bundled files and configuration sources
  • Asynchronous Loading: Loads translations asynchronously during application startup
  • User Locale Detection: Automatically detects and applies the user's preferred language
  • Fallback Mechanism: Uses English as fallback when translations are missing
  • Error Handling: Comprehensive error handling for missing or invalid translations

Implementation Details

  • i18n Core Setup: Configures i18next with React bindings and browser language detection
    Translation Service:
  • getUserPreferredLocale(): Retrieves user's language preference from localStorage
  • getTranslations(): Fetches and merges translations from bundled and config sources
  • getMergedTranslations(): Handles merging with config translations taking precedence
  • TranslationProvider: Provides React Suspense-based loading state while translations are being fetched

Constants & Configuration:

  • URL templates for both bundled and config translation sources
  • Default locale and namespace settings
  • Cookie/localStorage configuration
  • Testing & Type Definitions: Includes comprehensive unit tests, integration tests, and TypeScript type definitions

Screenshot 2025-04-21 at 3 02 46 PM

NOTE: No new translation keys have been introduced, except in cases where a corresponding key does not already exist in the existing Bahmni Apps i18n locale files.
NOTE: The i18n implementation expects at least the english translation key file to be present either bundled or at the configuration source, without which the frontend will throw an error.

arshiyaTW2021 and others added 30 commits April 17, 2025 10:42
@rahu1ramesh rahu1ramesh requested a review from mohan-13 April 21, 2025 09:36
@mohan-13 mohan-13 merged commit 8cbefcf into main Apr 22, 2025
2 checks passed
@mohan-13 mohan-13 deleted the BN-41 branch April 22, 2025 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants