refactor(i18n): move translations to JSON locale files

- Extract 1149 translation keys from i18n.py into locales/ru.json and locales/en.json
- Rewrite i18n.py as a lightweight JSON loader (5287 → 128 lines)
- Add I18nService.reload() for runtime hot-reload without restart
- Add I18nService.available_languages() to list loaded language codes
- Public API unchanged: t(), get(), get_all(), add_translation()
- New languages require only a new *.json file in locales/ — no code changes

Bump version: 1.1.6 → 1.1.7
This commit is contained in:
markmorado
2026-03-16 04:08:28 +01:00
parent 4940cbe77f
commit c09c0c5b63
7 changed files with 2421 additions and 5262 deletions

View File

@@ -4,6 +4,18 @@ All notable changes to PVEmanager will be documented in this file.
---
## [v1.1.7] - 2026-03-16
### 🌍 i18n — Translation Files Refactored
- **Translations moved to JSON locale files** — all 1 149 translation keys extracted from the Python source into `backend/app/locales/ru.json` and `backend/app/locales/en.json`
- **`i18n.py` reduced from 5 287 → 128 lines** — now a lightweight JSON loader with lazy initialisation; zero changes to the public API (`t()`, `I18nService.get()`, `.get_all()`, `.add_translation()`)
- **Adding a new language requires no code changes** — drop a `xx.json` file into `backend/app/locales/` and it is picked up automatically on next startup
- **`I18nService.reload()`** — new method that reloads all locale files at runtime without a container restart; useful for live translation editing
- **`I18nService.available_languages()`** — returns the list of language codes currently loaded from disk
---
## [v1.1.6] - 2026-03-16
### 🖥️ LXC Terminal — xterm.js Console Fixed

View File

@@ -4,7 +4,7 @@
**Modern web panel for managing Proxmox servers, virtual machines and LXC containers**
[![Version](https://img.shields.io/badge/version-1.1.6-blue?style=flat-square)](CHANGELOG.md)
[![Version](https://img.shields.io/badge/version-1.1.7-blue?style=flat-square)](CHANGELOG.md)
[![License](https://img.shields.io/badge/license-MIT-green?style=flat-square)](LICENSE)
[![Docker](https://img.shields.io/badge/docker-ready-2496ED?style=flat-square&logo=docker&logoColor=white)](compose.yml)
[![Python](https://img.shields.io/badge/python-3.12-3776AB?style=flat-square&logo=python&logoColor=white)](backend/)

View File

@@ -1 +1 @@
1.1.6
1.1.7

22
WIKI.md
View File

@@ -1,6 +1,6 @@
# 📖 PVEmanager - Documentation
> Complete guide for installation, configuration and usage of PVEmanager v1.1.6
> Complete guide for installation, configuration and usage of PVEmanager v1.1.7
---
@@ -1191,17 +1191,21 @@ Access via **Settings → Security**:
### Adding New Language
1. Open `backend/app/i18n.py`
2. Add translation for each key:
Translations are stored as flat JSON files in `backend/app/locales/`.
To add a new language, simply create a new file — no code changes required:
```python
"key_name": {
"ru": "Russian text",
"en": "English text",
"uz": "O'zbek matni" # New language
}
```bash
# Create a new locale file for Uzbek
cp backend/app/locales/en.json backend/app/locales/uz.json
# Then translate the values in uz.json
```
The file name becomes the language code (`uz.json` → `"uz"`). The panel picks
it up automatically on next startup (or call `I18nService.reload()` at runtime).
> **Structure:** each file is a flat `{"key": "translated string"}` JSON object.
> Keys must match the existing keys in `ru.json` / `en.json`.
---
## ⚙️ Settings

File diff suppressed because it is too large Load Diff

1151
backend/app/locales/en.json Normal file

File diff suppressed because it is too large Load Diff

1151
backend/app/locales/ru.json Normal file

File diff suppressed because it is too large Load Diff