# yourwaifu/deadlock-language-tool architecture

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

- Interactive diagram: https://gitdiagram.com/yourwaifu/deadlock-language-tool
- Repository: https://github.com/yourwaifu/deadlock-language-tool

## Overview

##### Project Type & Purpose
- This project is an automatic translation tool designed to convert game text from one language to another. It is not a full-scale translator but provides a “better than nothing” automated solution.
- The tool supports multiple languages (e.g., Shavian, Traditional Chinese, Japanese, Thai) and is intended to process game localization files, convert text (with variables, formatting, XML content, etc.), and prepare the resulting resources for integration into the game’s directory structure.
- The README explains a step-by-step pipeline—from resource copying to running language-specific scripts (like shavian.js)—and then relocating the output to game directories and updating configuration files (fonts.conf and boot.vcfg).

##### File Structure – Main Components
- Scripts and Core Modules:
– Files such as core.js, english.js, shavian.js, tchinese.js, google-test.js represent the translation engine. They probably encapsulate language-specific logic, conversion rules, and tests against external APIs (e.g., for Google Translate).
- Server Files:
– server.js likely provides a backend or a lightweight serving mechanism, which might be used for testing or previewing translations.
- Assets & Resources:
– The images folder, with various CSS diff files and VTex (likely proprietary asset formats), indicates that the project also involves managing assets related to HUDs and images.
– The presence of fonts.conf in the images folder suggests that font configuration is a part of making translations work properly, particularly for languages/scripts with unique font needs.
- Web Client:
– The contained web directory, especially web/client (with index.html) and web/js (with index.js), represents a frontend component. This could provide a user interface for previewing translations, testing output, or even configuring the tool.
- Miscellaneous:
– Files like sample-game-text.txt and sample-translator-input.html may be used to test or demonstrate how the translation process works.
– Configuration & Dependency Files: package.json and package-lock.json define dependencies and scripts needed to run the tool.

##### Key Architectural Components
a. Translation Engine:
– A central “Translation Engine” module comprising core.js and language-specific scripts (shavian.js, tchinese.js, english.js, etc.).
– Include an external API integration component if google-test.js is testing such functionality.
– Show processing stages: Reading raw game text, handling variables/formatting/XML, then outputting translated text.
b. Resource Pipeline / Integration:
– A “Resource Manager” component that deals with copying resources from the game’s localization directory to the project’s resources folder and vice versa.
– Indicate tools for packaging the output (zipping the translated resources) for publishing.
c. Server / Backend Service:
– Represent server.js as an optional backend or test service that might expose APIs or serve local previews.
d. Web Frontend Interface:
e. Assets & Configuration:
– Note the “Assets” (CSS, VTex files, images) and “Font Configuration” (fonts.conf) that work alongside the translation outputs.
– Highlight the configuration file (boot.vcfg) editing step mentioned in the README.

##### Relationships & Data Flow
- Flow: Translation Engine processes the text (using language-specific modules) and outputs translated files.
- From the Translation Engine, indicate integration with the Resource Manager, which then packages and places the translated output in the correct game directories.
- Optionally, illustrate external API calls (if applicable) from the Translation Engine to services (e.g., Google Translate).

##### Architectural Patterns & Design Principles
- The design follows a modular approach, with separation between core translation functionality, language-specific handling, resource management, and user interaction.
- Layering: Input → Processing (translation) → Output (resource packaging and integration).
- If applicable, show dependency inversion by indicating that each language script can plug into the core engine.
- “pipeline” structure present in the resource flow.

## Diagram (Mermaid)

```mermaid
flowchart TD
    GTI["Game Text Input"]:::input

    subgraph "Translation Engine"
        Core["core.js"]:::engine
        English["english.js"]:::engine
        Shavian["shavian.js"]:::engine
        TChinese["tchinese.js"]:::engine
        GoogleTest["google-test.js"]:::engine
    end

    RM["Resource Manager"]:::resource
    GO["Game Localization Output"]:::output
    Assets["Assets & Configuration"]:::assets
    ExtAPI["Google API"]:::external

    subgraph "Web Frontend"
        HTML["index.html"]:::frontend
        JS["index.js"]:::frontend
    end

    SB["Server Backend (server.js)"]:::backend

    %% Data Flow Connections
    GTI -->|"to engine"| Core
    Core -->|"calls"| English
    Core -->|"calls"| Shavian
    Core -->|"calls"| TChinese
    Core -->|"calls"| GoogleTest
    GoogleTest -->|"integrates"| ExtAPI
    Core -->|"processes"| RM
    Assets -->|"supplies"| RM
    RM -->|"outputs"| GO

    %% Web & Server Interactions
    HTML -->|"request"| SB
    SB -->|"response"| JS

    %% Click Events
    click Core "https://github.com/yourwaifu/deadlock-language-tool/blob/main/core.js"
    click English "https://github.com/yourwaifu/deadlock-language-tool/blob/main/english.js"
    click Shavian "https://github.com/yourwaifu/deadlock-language-tool/blob/main/shavian.js"
    click TChinese "https://github.com/yourwaifu/deadlock-language-tool/blob/main/tchinese.js"
    click GoogleTest "https://github.com/yourwaifu/deadlock-language-tool/blob/main/google-test.js"
    click SB "https://github.com/yourwaifu/deadlock-language-tool/blob/main/server.js"
    click HTML "https://github.com/yourwaifu/deadlock-language-tool/blob/main/web/client/index.html"
    click JS "https://github.com/yourwaifu/deadlock-language-tool/blob/main/web/js/index.js"
    click Assets "https://github.com/yourwaifu/deadlock-language-tool/tree/main/images"

    %% Style Definitions
    classDef engine fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef resource fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef output fill:#FFD700,stroke:#000,stroke-width:1px;
    classDef assets fill:#D3D3D3,stroke:#000,stroke-width:1px;
    classDef backend fill:#FFFFE0,stroke:#000,stroke-width:1px;
    classDef frontend fill:#FFB6C1,stroke:#000,stroke-width:1px;
    classDef external fill:#E0FFFF,stroke:#000,stroke-width:1px;
    classDef input fill:#fafad2,stroke:#000,stroke-width:1px;
```
