mirror of
https://git.quad4.io/RNS-Things/MeshChatX.git
synced 2026-04-25 11:02:11 +00:00
docs(readme): update
This commit is contained in:
31
README.md
31
README.md
@@ -193,7 +193,7 @@ task dist:fe:rpm
|
||||
- Linux DEB: `x64`, `arm64`
|
||||
- Windows: `x64`, `arm64` (build scripts available)
|
||||
- macOS: build scripts available (`arm64`, `universal`) for local build environments
|
||||
- Android: native APKs — ABIs `arm64-v8a`, `x86_64`, plus universal
|
||||
- Android: native APKs — ABIs `arm64-v8a`, `x86_64`, `armeabi-v7a` (32-bit ARM), plus universal
|
||||
|
||||
## Android
|
||||
|
||||
@@ -218,19 +218,22 @@ Debug (`android/app/build/outputs/apk/debug/`):
|
||||
|
||||
- `app-arm64-v8a-debug.apk` (ARM64 devices)
|
||||
- `app-x86_64-debug.apk` (x86_64 emulators)
|
||||
- `app-armeabi-v7a-debug.apk` (32-bit ARM devices)
|
||||
- `app-universal-debug.apk` (all bundled ABIs in one package)
|
||||
|
||||
Release (`android/app/build/outputs/apk/release/`):
|
||||
|
||||
- `app-arm64-v8a-release-unsigned.apk`
|
||||
- `app-x86_64-release-unsigned.apk`
|
||||
- `app-armeabi-v7a-release-unsigned.apk`
|
||||
- `app-universal-release-unsigned.apk`
|
||||
|
||||
Notes:
|
||||
|
||||
- Release outputs are unsigned by default unless you configure signing.
|
||||
- If you only need one variant, run `:app:assembleDebug` or `:app:assembleRelease`.
|
||||
- Android targets `arm64-v8a` and `x86_64` ABIs as configured in `android/app/build.gradle`.
|
||||
- Android targets the ABIs listed in `android/app/build.gradle` (including `armeabi-v7a` when enabled). Building wheels for `armeabi-v7a` needs an Android SDK on `ANDROID_HOME` (see `android/README.md`).
|
||||
- You can override ABI selection per build with `-PmeshchatxAbis=<comma-separated list>`, for example `-PmeshchatxAbis=armeabi-v7a`. Universal APKs are emitted only when multiple ABIs are selected.
|
||||
|
||||
Additional docs:
|
||||
|
||||
@@ -306,27 +309,21 @@ Security and integrity details:
|
||||
|
||||
## Adding a Language
|
||||
|
||||
Locale discovery is automatic. To add a new language, create a single JSON file:
|
||||
Locale discovery is automatic. Add a new file under `meshchatx/src/frontend/locales/` (for example `xx.json`) with the same keys as `en.json` and a top-level `_languageName` string for the label shown in the language selector. You can copy `en.json` and translate every value by hand; **machine-assisted generation is optional** and never required.
|
||||
|
||||
1. Generate a blank template from `en.json`:
|
||||
**Optional: Argos Translate bootstrap** -- If you want a machine-generated first draft from `en.json`, you can use `scripts/argos_translate.py`. It handles formatting, color output, and helps protect interpolation variables (like `{count}`) from accidental edits.
|
||||
|
||||
```bash
|
||||
python scripts/generate_locale_template.py
|
||||
# Install argostranslate if you haven't already
|
||||
pipx install argostranslate
|
||||
|
||||
# Run the translation script
|
||||
python scripts/argos_translate.py --from en --to xx --input meshchatx/src/frontend/locales/en.json --output meshchatx/src/frontend/locales/xx.json --name "Your Language Name"
|
||||
```
|
||||
|
||||
This writes `locales.json` with every key set to an empty string.
|
||||
After any machine-assisted pass, have an LLM or a human reviewer verify grammar, context, and tone (for example formal vs informal).
|
||||
|
||||
2. Rename it to your language code and move it into the locales directory:
|
||||
|
||||
```bash
|
||||
mv locales.json meshchatx/src/frontend/locales/xx.json
|
||||
```
|
||||
|
||||
3. Set `_languageName` at the top of the file to the native name of the language (e.g. `"Espanol"`, `"Francais"`). This is displayed in the language selector.
|
||||
|
||||
4. Translate all remaining values.
|
||||
|
||||
5. Run `pnpm test -- tests/frontend/i18n.test.js --run` to verify key parity with `en.json`.
|
||||
Run `pnpm test -- tests/frontend/i18n.test.js --run` to verify key parity with `en.json`.
|
||||
|
||||
No other code changes are required. The app, language selector, and tests all discover locales from the `meshchatx/src/frontend/locales/` directory at build time.
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ Prerequisites:
|
||||
|
||||
- **JDK 17 or newer** (required by the Android Gradle Plugin used in this project). On distributions with multiple JDKs, point the build at JDK 17+ (for example `JAVA_HOME` for the Gradle invocation).
|
||||
- **Android SDK** with API **34** platform and **Build-Tools 34** installed. Set `ANDROID_HOME` and `ANDROID_SDK_ROOT` to the SDK root (the same directory for both is fine).
|
||||
- **Host build tools for wheel patching**: `patchelf`, `cmake`, `pkg-config`, `unzip`, and build essentials (`gcc`, `make`, headers). On Arch-based systems, install `patchelf cmake pkgconf base-devel rustup unzip`.
|
||||
- **`android/vendor/`** must contain the Chaquopy vendor wheels (see [Updating Android Python ABI Wheels](#updating-android-python-abi-wheels-python-311)). The build fails fast if this directory is missing or incomplete.
|
||||
- **MeshChatX Python sources** at the repository root (`meshchatx/`). The build syncs them into the app before compiling.
|
||||
|
||||
@@ -21,19 +22,19 @@ SDK licenses:
|
||||
- Install Command-line Tools if needed: download the package for your OS from [Android Studio command-line tools](https://developer.android.com/studio#command-tools), extract it so you have `cmdline-tools/latest/bin/sdkmanager` under `ANDROID_HOME` (the inner folder is often named `latest`; see Google’s layout for that zip).
|
||||
- Accept licenses (writes under the SDK; use sudo if the SDK is root-owned):
|
||||
|
||||
```text
|
||||
```bash
|
||||
yes | path/to/cmdline-tools/latest/bin/sdkmanager --licenses
|
||||
```
|
||||
|
||||
- Install missing packages if the build still complains (platform 34, build-tools 34, etc.):
|
||||
|
||||
```text
|
||||
```bash
|
||||
path/to/cmdline-tools/latest/bin/sdkmanager "platforms;android-34" "build-tools;34.0.0"
|
||||
```
|
||||
|
||||
Build from the `android/` directory:
|
||||
|
||||
```text
|
||||
```bash
|
||||
./gradlew assembleDebug
|
||||
```
|
||||
|
||||
@@ -41,11 +42,83 @@ Debug APK outputs (ABI splits plus universal) are written under `app/build/outpu
|
||||
|
||||
- `app-arm64-v8a-debug.apk`
|
||||
- `app-x86_64-debug.apk`
|
||||
- `app-armeabi-v7a-debug.apk`
|
||||
- `app-universal-debug.apk`
|
||||
|
||||
By default all ABIs are included. To build only specific ABIs, pass a property:
|
||||
|
||||
```bash
|
||||
./gradlew assembleDebug -PmeshchatxAbis=armeabi-v7a
|
||||
./gradlew assembleDebug -PmeshchatxAbis=arm64-v8a,x86_64
|
||||
```
|
||||
|
||||
`app-universal-*.apk` is produced only when more than one ABI is selected.
|
||||
|
||||
## Signing Release APKs (optional SourceStamp)
|
||||
|
||||
Build release APKs first:
|
||||
|
||||
```bash
|
||||
./gradlew --no-daemon :app:assembleRelease
|
||||
```
|
||||
|
||||
Create a release signing key (one time):
|
||||
|
||||
```bash
|
||||
mkdir -p android/keystore
|
||||
keytool -genkeypair -v \
|
||||
-keystore android/keystore/meshchatx-release.jks \
|
||||
-alias meshchatx-release \
|
||||
-keyalg RSA \
|
||||
-keysize 4096 \
|
||||
-validity 9125
|
||||
```
|
||||
|
||||
Optional: create a separate SourceStamp key (recommended if you use SourceStamp):
|
||||
|
||||
```bash
|
||||
keytool -genkeypair -v \
|
||||
-keystore android/keystore/meshchatx-stamp.jks \
|
||||
-alias meshchatx-stamp \
|
||||
-keyalg RSA \
|
||||
-keysize 4096 \
|
||||
-validity 9125
|
||||
```
|
||||
|
||||
Sign all `*-unsigned.apk` release artifacts:
|
||||
|
||||
```bash
|
||||
ANDROID_HOME="$HOME/Android/sdk" \
|
||||
SIGNING_KEYSTORE_PATH=android/keystore/meshchatx-release.jks \
|
||||
SIGNING_KEY_ALIAS=meshchatx-release \
|
||||
SIGNING_KEYSTORE_PASSWORD='<release-keystore-password>' \
|
||||
SIGNING_KEY_PASSWORD='<release-key-password>' \
|
||||
bash scripts/sign-android-apks.sh
|
||||
```
|
||||
|
||||
Sign with SourceStamp enabled:
|
||||
|
||||
```bash
|
||||
ANDROID_HOME="$HOME/Android/sdk" \
|
||||
SIGNING_KEYSTORE_PATH=android/keystore/meshchatx-release.jks \
|
||||
SIGNING_KEY_ALIAS=meshchatx-release \
|
||||
SIGNING_KEYSTORE_PASSWORD='<release-keystore-password>' \
|
||||
SIGNING_KEY_PASSWORD='<release-key-password>' \
|
||||
ENABLE_SOURCESTAMP=true \
|
||||
SOURCESTAMP_KEYSTORE_PATH=android/keystore/meshchatx-stamp.jks \
|
||||
SOURCESTAMP_KEY_ALIAS=meshchatx-stamp \
|
||||
SOURCESTAMP_KEYSTORE_PASSWORD='<stamp-keystore-password>' \
|
||||
SOURCESTAMP_KEY_PASSWORD='<stamp-key-password>' \
|
||||
bash scripts/sign-android-apks.sh
|
||||
```
|
||||
|
||||
The helper script auto-detects the newest Android Build-Tools, runs `zipalign`, signs with `apksigner`, and verifies each output certificate/signature block.
|
||||
|
||||
## Updating Android Python ABI Wheels (Python 3.11)
|
||||
|
||||
Use this workflow when a dependency (for example `cryptography`) requires custom Android wheels for `arm64-v8a` and `x86_64`.
|
||||
Use this workflow when a dependency (for example `cryptography`) requires custom Android wheels for the ABIs listed in `app/build.gradle` (`ndk.abiFilters`).
|
||||
|
||||
For **`armeabi-v7a`**, Chaquopy usually has no prebuilt NumPy wheel; `scripts/build-android-wheels-local.sh` builds NumPy from source and must cache the official `chaquopy-openblas` wheel (handled in the script) and run with **`ANDROID_HOME`** pointing at an SDK that includes **Command-line Tools** and NDK **27.3.13750724** (Chaquopy’s `target/android-env.sh` installs the NDK via `sdkmanager` if missing).
|
||||
|
||||
1. Build wheels in a Podman Python 3.11 container to avoid host Python mismatches:
|
||||
- Use `docker.io/library/python:3.11-bookworm`.
|
||||
@@ -56,12 +129,27 @@ Use this workflow when a dependency (for example `cryptography`) requires custom
|
||||
2. Keep custom Chaquopy recipes in `android/chaquopy-recipes/<package>-<major>/`:
|
||||
- Define package/version in `meta.yaml`.
|
||||
- Store source patches in `patches/`.
|
||||
3. Build both ABIs with Chaquopy `build-wheel.py` and place final wheels in `android/vendor/`.
|
||||
3. Build the configured ABIs with Chaquopy `build-wheel.py` (via `scripts/build-android-wheels-local.sh`) and place final wheels in `android/vendor/`.
|
||||
4. Update `android/app/build.gradle` `pip` installs to the new pinned version.
|
||||
5. Rebuild with `./gradlew assembleDebug` and verify split outputs:
|
||||
- `app-arm64-v8a-debug.apk`
|
||||
- `app-x86_64-debug.apk`
|
||||
- `app-universal-debug.apk`
|
||||
5. Rebuild with `./gradlew assembleDebug` and verify split outputs (per enabled ABIs), including `app-universal-debug.apk`.
|
||||
|
||||
Local host build example (no shell startup files required):
|
||||
|
||||
```bash
|
||||
cd /path/to/reticulum-meshchatX
|
||||
ANDROID_HOME="$HOME/Android/sdk" \
|
||||
ANDROID_SDK_ROOT="$HOME/Android/sdk" \
|
||||
PYTHON_BIN="$(uv python find 3.11)" \
|
||||
bash scripts/build-android-wheels-local.sh --abis armeabi-v7a
|
||||
```
|
||||
|
||||
If `uv` does not have Python 3.11 yet, install it first:
|
||||
|
||||
```bash
|
||||
uv python install 3.11
|
||||
```
|
||||
|
||||
If the wheel build fails with `No such file or directory: 'patchelf'`, install `patchelf` and re-run the same command.
|
||||
|
||||
Notes:
|
||||
- For Rust-backed wheels (such as modern `cryptography`), build inside the container with Rust toolchain available.
|
||||
@@ -72,7 +160,7 @@ Notes:
|
||||
This project keeps Android-specific Chaquopy recipes in `android/chaquopy-recipes/` to bridge gaps between desktop Python dependencies and Android wheel availability.
|
||||
|
||||
- `cryptography-46`
|
||||
- Purpose: provide Android ABI wheels for `cryptography 46.0.7` (`arm64-v8a`, `x86_64`) because upstream Chaquopy index only provided older builds.
|
||||
- Purpose: provide Android ABI wheels for `cryptography 46.0.7` for each ABI in the wheel script (for example `arm64-v8a`, `x86_64`, `armeabi-v7a`) because upstream Chaquopy index only provided older builds.
|
||||
- `patches/openssl_no_legacy.patch`: disables OpenSSL legacy provider loading, which is unavailable in the bundled Android OpenSSL runtime.
|
||||
- `patches/pyo3_no_interpreter.patch`: enables compatible `pyo3` ABI settings for Chaquopy Python 3.11 Android builds.
|
||||
|
||||
|
||||
@@ -301,27 +301,23 @@ Fuer konsistente Releases die Versionsfelder dort abgleichen, wo noetig (`packag
|
||||
|
||||
## Sprache hinzufuegen
|
||||
|
||||
Die Spracherkennung erfolgt automatisch. Um eine neue Sprache hinzuzufuegen, genuegt eine einzige JSON-Datei:
|
||||
Die Locale-Erkennung erfolgt automatisch. Legen Sie eine neue Datei unter `meshchatx/src/frontend/locales/` an (z. B. `xx.json`) mit denselben Schluesseln wie `en.json` und einem obersten Feld `_languageName` fuer die Anzeige in der Sprachauswahl. Sie koennen `en.json` kopieren und alles von Hand uebersetzen; **maschinelle Erzeugung ist optional** und nie verpflichtend.
|
||||
|
||||
1. Leere Vorlage aus `en.json` erzeugen:
|
||||
**Korrekturen und menschliche Uebersetzungen sind willkommen.** Verbesserungen an bestehenden Locale-Dateien oder vollstaendig manuell uebersetzte Dateien koennen Sie per Pull Request oder Issue im [Quellcode-Repository](https://git.quad4.io/RNS-Things/MeshChatX) oder beim [GitHub-Spiegel](https://github.com/Sudo-Ivan/MeshChatX) einreichen.
|
||||
|
||||
**Optional: Argos-Translate-Bootstrap** -- Wenn Sie einen maschinellen Erstentwurf aus `en.json` wollen, koennen Sie `scripts/argos_translate.py` nutzen. Es kuemmert sich um Formatierung und schuetzt Interpolationsvariablen (wie `{count}`) vor versehentlichen Aenderungen.
|
||||
|
||||
```bash
|
||||
python scripts/generate_locale_template.py
|
||||
# Installieren Sie argostranslate, falls noch nicht geschehen
|
||||
pip install argostranslate
|
||||
|
||||
# Fuehren Sie das Uebersetzungsskript aus
|
||||
python scripts/argos_translate.py --from en --to xx --input meshchatx/src/frontend/locales/en.json --output meshchatx/src/frontend/locales/xx.json --name "Ihr Sprachname"
|
||||
```
|
||||
|
||||
Damit wird `locales.json` mit leeren Strings fuer alle Schluessel geschrieben.
|
||||
Nach einem maschinellen Entwurf sollten ein LLM oder ein Mensch Grammatik, Kontext und Ton pruefen (z. B. formell vs. informell).
|
||||
|
||||
2. Umbenennen und in das Locale-Verzeichnis verschieben:
|
||||
|
||||
```bash
|
||||
mv locales.json meshchatx/src/frontend/locales/xx.json
|
||||
```
|
||||
|
||||
3. `_languageName` am Anfang der Datei auf den nativen Sprachnamen setzen (z.B. `"Espanol"`, `"Francais"`). Wird im Sprachwahlmenue angezeigt.
|
||||
|
||||
4. Alle uebrigen Werte uebersetzen.
|
||||
|
||||
5. Schluesselparitaet pruefen: `pnpm test -- tests/frontend/i18n.test.js --run`
|
||||
Schluesselparitaet pruefen: `pnpm test -- tests/frontend/i18n.test.js --run`
|
||||
|
||||
Keine weiteren Code-Aenderungen noetig. App, Sprachwahl und Tests lesen Locales zur Build-Zeit aus `meshchatx/src/frontend/locales/`.
|
||||
|
||||
|
||||
@@ -301,29 +301,25 @@ Per release coerenti, allineare i campi di versione dove richiesto (`package.jso
|
||||
|
||||
## Aggiungere una lingua
|
||||
|
||||
Il rilevamento delle lingue e automatico. Per aggiungere una nuova lingua basta un singolo file JSON:
|
||||
Il rilevamento della lingua locale è automatico. Aggiungi un nuovo file in `meshchatx/src/frontend/locales/` (ad esempio `xx.json`) con le stesse chiavi di `en.json` e un campo in cima `_languageName` per l'etichetta nel selettore lingue. Puoi copiare `en.json` e tradurre tutto a mano; **la generazione automatica è opzionale** e non è mai obbligatoria.
|
||||
|
||||
1. Generare un modello vuoto da `en.json`:
|
||||
**Correzioni e traduzioni umane sono benvenute.** Miglioramenti a un file esistente o un file interamente tradotto a mano possono essere inviati con una pull request o una segnalazione sul [repository sorgente](https://git.quad4.io/RNS-Things/MeshChatX) o sul [mirror GitHub](https://github.com/Sudo-Ivan/MeshChatX).
|
||||
|
||||
**Opzionale: bozza con Argos Translate** -- Se vuoi una prima bozza generata da `en.json`, puoi usare `scripts/argos_translate.py`. Gestisce la formattazione e aiuta a proteggere le variabili di interpolazione (come `{count}`).
|
||||
|
||||
```bash
|
||||
python scripts/generate_locale_template.py
|
||||
# Installa argostranslate se non l'hai già fatto
|
||||
pip install argostranslate
|
||||
|
||||
# Esegui lo script di traduzione
|
||||
python scripts/argos_translate.py --from en --to xx --input meshchatx/src/frontend/locales/en.json --output meshchatx/src/frontend/locales/xx.json --name "Nome della tua lingua"
|
||||
```
|
||||
|
||||
Scrive `locales.json` con ogni chiave impostata a stringa vuota.
|
||||
Dopo una passata automatica, fai verificare grammatica, contesto e tono a un LLM o a un revisore umano (es. formale vs informale).
|
||||
|
||||
2. Rinominare e spostare nella cartella delle lingue:
|
||||
Verifica la parità delle chiavi con: `pnpm test -- tests/frontend/i18n.test.js --run`
|
||||
|
||||
```bash
|
||||
mv locales.json meshchatx/src/frontend/locales/xx.json
|
||||
```
|
||||
|
||||
3. Impostare `_languageName` all'inizio del file con il nome nativo della lingua (es. `"Espanol"`, `"Francais"`). Viene mostrato nel selettore lingua.
|
||||
|
||||
4. Tradurre tutti i valori rimanenti.
|
||||
|
||||
5. Verificare la corrispondenza delle chiavi: `pnpm test -- tests/frontend/i18n.test.js --run`
|
||||
|
||||
Nessun altra modifica al codice e necessaria. App, selettore lingua e test scoprono le lingue in `meshchatx/src/frontend/locales/` al momento della build.
|
||||
Non sono necessarie altre modifiche al codice. L'app, il selettore della lingua e i test scoprono le lingue dalla cartella `meshchatx/src/frontend/locales/` durante la compilazione.
|
||||
|
||||
## Crediti
|
||||
|
||||
|
||||
@@ -301,29 +301,25 @@ pnpm run version:sync
|
||||
|
||||
## 言語の追加
|
||||
|
||||
ロケールは自動検出されます。新しい言語には JSON ファイル 1 つで足ります:
|
||||
ロケールの検出は自動で行われます。`meshchatx/src/frontend/locales/` に新しい JSON(例: `xx.json`)を追加し、`en.json` と同じキーに加え、言語選択に表示する名前を `_languageName` で指定します。`en.json` をコピーしてすべて手翻訳しても構いません。**機械翻訳による生成は任意**で、必須ではありません。
|
||||
|
||||
1. `en.json` から空のテンプレートを生成:
|
||||
**修正や人間による翻訳の提供を歓迎します。** 既存ロケールの改善や完全な手翻訳ファイルは、[ソースリポジトリ](https://git.quad4.io/RNS-Things/MeshChatX)または [GitHub ミラー](https://github.com/Sudo-Ivan/MeshChatX) にプルリクエストまたは issue で送ってください。
|
||||
|
||||
**任意: Argos Translate による下書き** -- `en.json` から機械翻訳のたたき台が欲しい場合は `scripts/argos_translate.py` を使えます。フォーマット処理や補間変数(`{count}` など)の保護に役立ちます。
|
||||
|
||||
```bash
|
||||
python scripts/generate_locale_template.py
|
||||
# argostranslate をまだインストールしていない場合はインストールします
|
||||
pip install argostranslate
|
||||
|
||||
# 翻訳スクリプトを実行します
|
||||
python scripts/argos_translate.py --from en --to xx --input meshchatx/src/frontend/locales/en.json --output meshchatx/src/frontend/locales/xx.json --name "言語名"
|
||||
```
|
||||
|
||||
全キーを空文字にした `locales.json` が書き出されます。
|
||||
機械下書きのあとは、LLM または人間が文法・文脈・トーン(フォーマル/カジュアルなど)を確認するとよいでしょう。
|
||||
|
||||
2. 名前を変更してロケールディレクトリへ移動:
|
||||
`pnpm test -- tests/frontend/i18n.test.js --run` を実行して、`en.json` とのキーの一致を確認します。
|
||||
|
||||
```bash
|
||||
mv locales.json meshchatx/src/frontend/locales/xx.json
|
||||
```
|
||||
|
||||
3. ファイル先頭の `_languageName` にその言語の母語名を設定(例: `"Espanol"`, `"Francais"`)。言語選択に表示されます。
|
||||
|
||||
4. 残りの値をすべて翻訳。
|
||||
|
||||
5. キーの整合性を確認: `pnpm test -- tests/frontend/i18n.test.js --run`
|
||||
|
||||
他のコード変更は不要です。アプリ・言語選択・テストはビルド時に `meshchatx/src/frontend/locales/` からロケールを読み込みます。
|
||||
その他のコードの変更は必要ありません。アプリ、言語セレクター、およびテストは、ビルド時に `meshchatx/src/frontend/locales/` ディレクトリからロケールを検出します。
|
||||
|
||||
## クレジット
|
||||
|
||||
|
||||
@@ -301,29 +301,25 @@ pnpm run version:sync
|
||||
|
||||
## Добавление языка
|
||||
|
||||
Локали обнаруживаются автоматически. Достаточно одного JSON-файла:
|
||||
Обнаружение локали происходит автоматически. Добавьте новый файл в `meshchatx/src/frontend/locales/` (например `xx.json`) с теми же ключами, что и в `en.json`, и полем `_languageName` в начале для подписи в селекторе языка. Можно скопировать `en.json` и перевести всё вручную; **автоматическая генерация (Argos и т. п.) необязательна** и не требуется.
|
||||
|
||||
1. Сгенерировать пустой шаблон из `en.json`:
|
||||
**Исправления и переводы от людей приветствуются.** Улучшения существующих файлов локали или полностью ручной перевод можно прислать через pull request или issue в [исходном репозитории](https://git.quad4.io/RNS-Things/MeshChatX) или на [зеркале GitHub](https://github.com/Sudo-Ivan/MeshChatX).
|
||||
|
||||
**По желанию: черновик через Argos Translate** -- если нужен машинный первый проход из `en.json`, можно использовать `scripts/argos_translate.py`. Он обрабатывает форматирование и помогает защитить переменные интерполяции (например `{count}`).
|
||||
|
||||
```bash
|
||||
python scripts/generate_locale_template.py
|
||||
# Установите argostranslate, если вы еще этого не сделали
|
||||
pip install argostranslate
|
||||
|
||||
# Запустите скрипт перевода
|
||||
python scripts/argos_translate.py --from en --to xx --input meshchatx/src/frontend/locales/en.json --output meshchatx/src/frontend/locales/xx.json --name "Название вашего языка"
|
||||
```
|
||||
|
||||
Создаётся `locales.json` со всеми ключами и пустыми строками.
|
||||
После машинного черновика имеет смысл проверить грамматику, контекст и тон с помощью LLM или человека (формальный или неформальный стиль).
|
||||
|
||||
2. Переименовать и переместить:
|
||||
Проверьте совпадение ключей с помощью: `pnpm test -- tests/frontend/i18n.test.js --run`
|
||||
|
||||
```bash
|
||||
mv locales.json meshchatx/src/frontend/locales/xx.json
|
||||
```
|
||||
|
||||
3. В начале файла задать `_languageName` — нативное имя языка (например `"Espanol"`, `"Francais"`). Отображается в выборе языка.
|
||||
|
||||
4. Перевести остальные значения.
|
||||
|
||||
5. Проверить ключи: `pnpm test -- tests/frontend/i18n.test.js --run`
|
||||
|
||||
Других изменений кода не требуется. Приложение, селектор языка и тесты используют `meshchatx/src/frontend/locales/` на этапе сборки.
|
||||
Никаких других изменений в коде не требуется. Приложение, селектор языка и тесты обнаруживают локали из каталога `meshchatx/src/frontend/locales/` во время сборки.
|
||||
|
||||
## Авторы
|
||||
|
||||
|
||||
@@ -301,29 +301,25 @@ pnpm run version:sync
|
||||
|
||||
## 添加语言
|
||||
|
||||
语言由目录自动发现。添加新语言只需一个 JSON 文件:
|
||||
语言检测是自动的。在 `meshchatx/src/frontend/locales/` 下新增 JSON 文件(例如 `xx.json`),键与 `en.json` 一致,并在顶层设置 `_languageName` 作为语言选择器中的显示名称。可以复制 `en.json` 后完全人工翻译;**使用 Argos 等机器辅助生成是可选的**,并非必需。
|
||||
|
||||
1. 从 `en.json` 生成空白模板:
|
||||
**欢迎提交纠错与人工翻译。** 若修正现有语言文件或提交完整人工翻译,请通过合并请求或议题提交至[项目源码仓库](https://git.quad4.io/RNS-Things/MeshChatX)或 [GitHub 镜像](https://github.com/Sudo-Ivan/MeshChatX)。
|
||||
|
||||
**可选:Argos Translate 初稿** -- 若需要从 `en.json` 生成机器翻译初稿,可使用 `scripts/argos_translate.py`。它会处理格式并有助于保护插值变量(如 `{count}`)。
|
||||
|
||||
```bash
|
||||
python scripts/generate_locale_template.py
|
||||
# 如果尚未安装,请安装 argostranslate
|
||||
pip install argostranslate
|
||||
|
||||
# 运行翻译脚本
|
||||
python scripts/argos_translate.py --from en --to xx --input meshchatx/src/frontend/locales/en.json --output meshchatx/src/frontend/locales/xx.json --name "您的语言名称"
|
||||
```
|
||||
|
||||
将写入 `locales.json`,所有键值为空字符串。
|
||||
机器初稿之后,建议由 LLM 或人工审校语法、语境与语气(如正式与非正式)。
|
||||
|
||||
2. 重命名并移入语言目录:
|
||||
运行 `pnpm test -- tests/frontend/i18n.test.js --run` 验证与 `en.json` 的键一致性。
|
||||
|
||||
```bash
|
||||
mv locales.json meshchatx/src/frontend/locales/xx.json
|
||||
```
|
||||
|
||||
3. 在文件顶部设置 `_languageName` 为该语言的母语名称(例如 `"Espanol"`、`"Francais"`)。将显示在语言选择器中。
|
||||
|
||||
4. 翻译其余全部值。
|
||||
|
||||
5. 校验键一致性: `pnpm test -- tests/frontend/i18n.test.js --run`
|
||||
|
||||
无需其他代码更改。应用、语言选择与测试在构建时从 `meshchatx/src/frontend/locales/` 发现语言文件。
|
||||
不需要其他代码更改。应用程序、语言选择器和测试在构建时从 `meshchatx/src/frontend/locales/` 目录发现所有语言环境。
|
||||
|
||||
## 致谢
|
||||
|
||||
|
||||
Reference in New Issue
Block a user