# i18next/i18next architecture

> Architecture diagram of the GitHub repository i18next/i18next, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/i18next/i18next
- Repository: https://github.com/i18next/i18next

## Overview

##### Main Components

a) Core Framework Components (Central):
- Translator Engine (src/Translator.js)
- Resource Store (src/ResourceStore.js)
- Backend Connector (src/BackendConnector.js)
- Interpolator (src/Interpolator.js)
- Plural Resolver (src/PluralResolver.js)
- Language Utils (src/LanguageUtils.js)

b) Integration Layer:
- Event System (src/EventEmitter.js)
- Formatting System (src/Formatter.js)
- Plugin Architecture

c) External Components:
- Backend Services (for loading translations)
- Language Detection System
- Caching Layer
- Post-Processing Pipeline

##### Relationship Flows

**[Application] → [i18next Core]**
- ↓
**[Backend Connector] ← → [External Backend Services]**
- ↓
**[Resource Store] ← → [Cache Layer]**
- ↓
**[Translator Engine] → [Interpolator]**
- ↓
**[Plural Resolver] ← → [Language Utils]**
- ↓
**[Post Processors] ← → [Formatter]**

##### Implementation Details to Highlight

- Separation between sync and async operations
- Where caching occurs
- Where language detection happens
- Format processing pipeline

##### Additional Notes

- Version compatibility layers (shown by test/compatibility structure)
- TypeScript support (based on typescript/ directory)
- Framework integration points (based on ecosystem image in README)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Legend
        A1[Core Component]:::core
        A2[Integration Component]:::integration
        A3[Processing Component]:::processing
        A4[External Service]:::external
        A5[Utility Component]:::utility
    end

    subgraph "Core Framework"
        I18N[i18next Core]:::core
        TE[Translator Engine]:::core
        RS[Resource Store]:::core
    end

    subgraph "Integration Layer"
        BC[Backend Connector]:::integration
        ES[Event System]:::integration
        PP[Post Processors]:::integration
    end

    subgraph "Processing Components"
        INT[Interpolator]:::processing
        PR[Plural Resolver]:::processing
        FMT[Formatter]:::processing
    end

    subgraph "External Services"
        EBS[Backend Services]:::external
        LD[Language Detection]:::external
        CL[Cache Layer]:::external
    end

    subgraph "Utilities"
        LU[Language Utils]:::utility
        TS[TypeScript Support]:::utility
        COMPAT[Compatibility Layer]:::utility
    end

    APP[Application] --> I18N
    I18N --> BC
    BC <--> EBS
    BC --> RS
    RS <--> CL
    RS --> TE
    TE --> INT
    TE --> PR
    PR <--> LU
    TE --> PP
    PP <--> FMT
    I18N <--> ES
    I18N <--> LD
    I18N -.-> TS
    I18N -.-> COMPAT

    %% Click events for component mapping
    click TE "https://github.com/i18next/i18next/blob/master/src/Translator.js"
    click RS "https://github.com/i18next/i18next/blob/master/src/ResourceStore.js"
    click BC "https://github.com/i18next/i18next/blob/master/src/BackendConnector.js"
    click INT "https://github.com/i18next/i18next/blob/master/src/Interpolator.js"
    click PR "https://github.com/i18next/i18next/blob/master/src/PluralResolver.js"
    click LU "https://github.com/i18next/i18next/blob/master/src/LanguageUtils.js"
    click ES "https://github.com/i18next/i18next/blob/master/src/EventEmitter.js"
    click FMT "https://github.com/i18next/i18next/blob/master/src/Formatter.js"
    click PP "https://github.com/i18next/i18next/blob/master/src/postProcessor.js"
    click I18N "https://github.com/i18next/i18next/blob/master/src/i18next.js"
    click LD "https://github.com/i18next/i18next/blob/master/test/runtime/languageDetector.test.js"
    click TS "https://github.com/i18next/i18next/tree/master/typescript/"
    click COMPAT "https://github.com/i18next/i18next/tree/master/test/compatibility/"

    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef integration fill:#4CAF50,stroke:#2E7D32,color:white
    classDef processing fill:#FF9800,stroke:#EF6C00,color:white
    classDef external fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef utility fill:#9E9E9E,stroke:#616161,color:white
```
