Multilingual & AI Translation

YeCha has two multilingual layers: UI strings (language packs) and content translations (ye_poly_contents). Language is identified purely by URL prefix — no cookies — so links are shareable and indexable.

On this page

Enable & URL rules

OptionMeaning
plugin.poly.enabledEnables the plugin and the Multilingual admin module
site.languagesEnabled languages, e.g. ["zh","en"]
site.default_langBase language for original content
site.name_en / site.subtitle_enSite name and tagline in the English UI
  • Chinese: /, /docs-install.html, /category/guide/
  • English: /en/, /en/docs-install.html, /en/category/guide/
  • Router strips the first segment only when the language is enabled and Poly::on() is true; otherwise /ja/… is a 404.
  • Build internal links with ui_lp(); taxonomy links with Poly::termUrl().
Known existing behaviour: plugin pages (/theme, /plugin, /downloads, /enterprise, …) return 404 under /ja/, /ko/ and similar prefixes. The official site currently exposes Chinese and /en/ only; content pages are unaffected.

Language packs

Packs live in lang/*.php and return key/value arrays read via __('nav.docs'); Lang::short() gives the current code.

When adding a nav item or button:

  1. Use a language key as label in Nav::defs();
  2. Add the same key to lang/zh_CN.php and lang/en_US.php;
  3. Uncovered languages fall back to the base language — never hard-code Chinese into views.

Content translations

ye_poly_contents is keyed by group_id (base content id) + lang:

FieldMeaning
group_id / lang / statusOwner, language, publish state (only publish is visible)
title / slug / excerpt / contentTranslated fields
description / keywordsTranslated SEO
manual_override / ai_generated / ai_revision / staleManual-edit protection, AI flags, revision, stale marker
source_lang / last_ai_atSource language, last AI run

Front end uses Poly::row($baseId, $lang); a missing or unpublished translation falls back to the base language. Lists use Poly::publishedList($lang, $limit).

Term translations

FieldMeaning
names_i18nJSON, e.g. {"en":"Guides","ja":"ガイド"}
name_enLegacy short English name
slug_i18nPer-language URL aliases
countPrecomputed post count, shared across languages

Use Poly::termName($row, $lang) and Poly::termUrl($type, $row); printing $row['name'] directly leaks Chinese into English pages.

AI translation

The AI translate button in the posts/pages list translates one item into every enabled language. Versions 1.2.2 / 1.2.3 specifically hardened it:

MechanismPurpose
One language per requestNo more serial translation of all languages in a single HTTP request (which saturated PHP-FPM with long network waits)
Per-cid file lock (300s TTL)Prevents double-clicks stacking processes
Session queue + meta-refresh auto-chainN languages become N short chained requests with an iteration safety valve
set_time_limit(30) + 20s API timeoutHard wall clock, fast failure
Overwrite mode (force)Re-translates existing languages but protects manual_override rows
Language validation + 2 retriesJapanese must contain kana, Korean Hangul, Latin languages letters and not pure Han; failures retry with a stronger prompt, then fail loudly — never stored
Chain toleranceOne failed language no longer stops the batch; a final report lists success/skipped/failed

The system prompt requires fluent native target-language writing with no Chinese retained, reducing source-text echo.

Traditional & RTL

  • core/ZhTw.php handles Simplified↔Traditional; tw deep pagination on large terms uses the ye_meta_page_bounds keyset fast path (1.2.4) with a safe fallback when the subset is smaller than limit.
  • RTL languages such as Arabic need theme support (dir="rtl"); the default theme has no RTL layout.
  • Language codes must match site.languages, otherwise Router will not recognise the prefix.

Troubleshooting

SymptomCheck
/en/xxx.html still ChineseTranslation missing or not publish; base-language fallback is expected — add it in Multilingual
Clicking a post returns to ChineseLink missed the language prefix; use ui_lp() / Poly::termUrl()
Category name is Chinese on the English pagenames_i18n lacks that language
AI result is still Chinese1.2.3 validation blocks it and reports an error; fix manually and set manual_override
Overwrite erased a manual editShould not happen (manual_override=1 is skipped); check the flag
/ja/theme is 404Existing behaviour for plugin pages, see URL rules
A button shows nav.xxxMissing language key — add it to lang/*.php

More: FAQ and user guide → i18n.