# How Localization Works with the --language Flag in Understand Anything

> Learn how the --language flag controls localization in Understand Anything. It configures your locale, injects it into LLM prompts, and updates UI strings for a seamless multilingual experience.

- Repository: [Egonex/Understand-Anything](https://github.com/Egonex-AI/Understand-Anything)
- Tags: how-to-guide
- Published: 2026-06-27

---

**The `--language` flag in Understand Anything triggers a multi-stage pipeline that persists your language choice to [`.understand-anything/config.json`](https://github.com/Egonex-AI/Understand-Anything/blob/main/.understand-anything/config.json), injects the locale into LLM prompts for graph generation, and swaps the dashboard UI strings at runtime.**

Understand Anything (from the Egonex-AI/Understand-Anything repository) ships with built-in localization that lets you generate knowledge graphs and UI content in multiple languages. By appending the `--language` flag to the main command, you activate a language-aware pipeline that stores your preference, validates it against the core schema, and ensures both the LLM-generated content and dashboard interface reflect your selected locale.

## Configuration Persistence and Auto-Detection

When you invoke the `/understand` command with `--language`, the entry-point script parses the flag and immediately writes the language code to [`.understand-anything/config.json`](https://github.com/Egonex-AI/Understand-Anything/blob/main/.understand-anything/config.json). This persistence layer means you only need to specify the flag once per project; subsequent runs automatically reuse the saved setting unless you override it. On the very first run, the system also attempts to auto-detect the language of your conversation and prompts you to confirm, streamlining setup for multilingual teams.

You can inspect the persisted configuration to verify the active locale:

```bash
cat .understand-anything/config.json

# → { "language": "zh" }

```

## Language-Aware Graph Generation

During the graph generation phase, the selected language code flows into the LLM prompts through the core type system. According to the source code in [`packages/core/src/types.ts`](https://github.com/Egonex-AI/Understand-Anything/blob/main/packages/core/src/types.ts), the system utilizes the `languages` array along with `languageNotes` and `languageLesson` fields to instruct the model to produce node summaries, descriptions, and educational content in the target language.

### Schema Validation

Before persisting the graph, the core schema validates the language field to ensure data integrity. The [`packages/core/src/schema.ts`](https://github.com/Egonex-AI/Understand-Anything/blob/main/packages/core/src/schema.ts) file contains Zod validation logic that confirms the language is a supported string and automatically strips any `null` values from the persisted nodes to prevent corruption of the knowledge graph.

## Dashboard UI Localization

The dashboard renders localized strings by importing locale objects from `packages/dashboard/src/locales/*.ts` (e.g., [`en.ts`](https://github.com/Egonex-AI/Understand-Anything/blob/main/en.ts), [`zh.ts`](https://github.com/Egonex-AI/Understand-Anything/blob/main/zh.ts), [`ja.ts`](https://github.com/Egonex-AI/Understand-Anything/blob/main/ja.ts)). At runtime, the application loads the corresponding locale bundle based on the configuration stored in your project root, swapping UI elements such as button labels, tooltips, and the "Languages" heading to match your selection.

## Usage Examples

Specify standard language codes like `zh` for Simplified Chinese, `zh-TW` for Traditional Chinese, or `ja` for Japanese when invoking the command:

```bash

# Generate the knowledge graph and UI in Simplified Chinese

/understand --language zh

# Switch to Traditional Chinese (zh-TW)

/understand --language zh-TW

# Use Japanese UI and node descriptions

/understand --language ja

# After the first run you can omit the flag – the saved language is reused

/understand

```

## Extending Localization with Custom Locales

To add support for a language not included in the default distribution, such as Spanish:

1. Create [`packages/dashboard/src/locales/es.ts`](https://github.com/Egonex-AI/Understand-Anything/blob/main/packages/dashboard/src/locales/es.ts) with the translated strings.
2. Export it in [`packages/dashboard/src/locales/index.ts`](https://github.com/Egonex-AI/Understand-Anything/blob/main/packages/dashboard/src/locales/index.ts).
3. Add `"es"` to the allowed values in [`packages/core/src/schema.ts`](https://github.com/Egonex-AI/Understand-Anything/blob/main/packages/core/src/schema.ts).
4. Run `/understand --language es` to generate the graph in Spanish.

## Summary

- The `--language` flag persists your choice to [`.understand-anything/config.json`](https://github.com/Egonex-AI/Understand-Anything/blob/main/.understand-anything/config.json) for automatic reuse across sessions.
- Language codes flow through [`packages/core/src/types.ts`](https://github.com/Egonex-AI/Understand-Anything/blob/main/packages/core/src/types.ts) to guide LLM generation of node descriptions and lesson content via `languageNotes` and `languageLesson`.
- [`packages/core/src/schema.ts`](https://github.com/Egonex-AI/Understand-Anything/blob/main/packages/core/src/schema.ts) validates language inputs with Zod and sanitizes null values before persistence.
- The dashboard renders localized strings from `packages/dashboard/src/locales/*.ts` based on the active configuration.

## Frequently Asked Questions

### Does Understand Anything auto-detect my language?

Yes. On the first run, the system attempts to auto-detect the language of your conversation and prompts you to confirm the selection. This makes it seamless for multilingual teams without requiring manual flag configuration, though you can always override it explicitly with `--language`.

### Where is the language setting stored between runs?

The selected language code is written to [`.understand-anything/config.json`](https://github.com/Egonex-AI/Understand-Anything/blob/main/.understand-anything/config.json) in your project root. This file acts as the source of truth for subsequent invocations, allowing you to omit the `--language` flag after the initial setup while maintaining consistency across the knowledge graph and dashboard.

### How do I add support for a language not included in the default distribution?

Create a new locale file in `packages/dashboard/src/locales/` (e.g., [`es.ts`](https://github.com/Egonex-AI/Understand-Anything/blob/main/es.ts) for Spanish), export it in the index file, and add the language code to the allowed values in [`packages/core/src/schema.ts`](https://github.com/Egonex-AI/Understand-Anything/blob/main/packages/core/src/schema.ts). The system will then recognize the new locale when you run `/understand --language <code>`.

### What happens if I pass an unsupported language code?

The Zod schema in [`packages/core/src/schema.ts`](https://github.com/Egonex-AI/Understand-Anything/blob/main/packages/core/src/schema.ts) validates the language field against supported values. If you provide an unsupported code, the validation will fail and prevent the graph from being persisted with invalid language data, ensuring the integrity of your generated knowledge base.