Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,13 @@ closed without a bump.
footprint under its own pin names. `get_component`, `list_parts` and `list_catalog` show
them. `add_part`'s description names every symbol and pin role the model has, written
from the model's own types: it had listed 6 of the 18 symbols.
- **The interface speaks Chinese.** `--lang zh`, or a `zh_CN` locale, opens the window and
every tooltip, menu, dialog and message in Simplified Chinese — a full catalogue beside
the Turkish one, translated from the English rather than through it, with the same
accelerators and the same placeholders. The build guide follows: its steps, checks,
orientation notes and cut list are written in Chinese too, with the page and the JSON
export tagged `zh`, and the MCP `generate_guide` tool takes `"language": "zh"`. The
language menu offers 中文, and the settings search finds a setting by its Chinese words.

### Changed

Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,9 @@ installer is code-signed by Medinstech**, and an update installs itself only fro
one. The macOS and Linux bundles are not signed yet, so they warn on first run and the
release notes say how to get past it. See [docs/RELEASING.md](https://github.com/medinstech/perfboard-studio/blob/main/docs/RELEASING.md).

The interface speaks **English and Turkish** (`--lang tr`, or follow the system locale),
and so does the build guide it writes — the steps, the checks, the cut list.
The interface speaks **English, Turkish and Simplified Chinese** (`--lang tr`, `--lang zh`, or
follow the system locale), and so does the build guide it writes — the steps, the checks,
the cut list.

### From PyPI

Expand Down Expand Up @@ -510,7 +511,7 @@ the board, modules on header strips drawn as what is on them, labels written on
KiCad netlists read part by part, parts described by their own measurements when the
library does not have them, parts on the panel wired to the board, solderless breadboards —
the circuit tried on one and then taken to perfboard, or soldered hole for hole on a
solderable one —, crash recovery, the MCP server, TR/EN localisation, the
solderable one —, crash recovery, the MCP server, English/Turkish/Chinese localisation, the
three-platform packaging that a `v*` tag runs, and the update check that tells you a release exists and fetches it (**Help ▸ Check
for Updates…**; it verifies the download against the release's `SHA256SUMS`, and on
Windows **Install and Restart** puts it in place behind the system's own prompt — nothing
Expand Down
7 changes: 4 additions & 3 deletions README.tr.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,9 @@ kendini yalnızca imzalı bir paketten kuruyor. macOS ve Linux paketleri henüz
o yüzden ilk açılışta uyarı veriyorlar ve release notları uyarının nasıl geçileceğini
yazıyor. Bkz. [docs/RELEASING.md](./docs/RELEASING.md).

Arayüz **İngilizce ve Türkçe** konuşur (`--lang tr`, ya da sistem diline göre otomatik);
yazdığı montaj rehberi de öyle — adımlar, kontroller, kesim listesi.
Arayüz **İngilizce, Türkçe ve Basitleştirilmiş Çince** konuşur (`--lang tr`, `--lang zh`, ya
da sistem diline göre otomatik); yazdığı montaj rehberi de öyle — adımlar, kontroller, kesim
listesi.

### PyPI'dan

Expand Down Expand Up @@ -514,7 +515,7 @@ kütüphanede olmayan parçaların kendi ölçüleriyle tarif edilmesi, karta te
panel parçaları, lehimsiz breadboard'lar — devre önce onda denenip sonra perfboard'a
taşınır ya da lehimlenebilir bir breadboard'a delik delik lehimlenir —,
çökme kurtarma, MCP
sunucusu, TR/EN yerelleştirme, bir `v*` etiketiyle çalışan üç platformluk paketleme, ve
sunucusu, TR/EN/ZH yerelleştirme, bir `v*` etiketiyle çalışan üç platformluk paketleme, ve
yeni sürümü haber verip indiren güncelleme denetimi
(**Yardım ▸ Güncellemeleri Denetle…**; indirdiğini sürümün `SHA256SUMS` dosyasıyla
doğrular, Windows'ta da **Kur ve Yeniden Başlat** onu sistemin kendi onay penceresinin
Expand Down
16 changes: 15 additions & 1 deletion docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2695,7 +2695,21 @@ over "0.64 mm", in either language. The engine's text cannot change, so the boxe
English in every Turkish window. `SAME_IN_BOTH` names the exceptions (Net, Jumper).
A count is said with `i18n.counted`, which picks one of two catalogued forms: "3 part(s)"
read like a machine, and Turkish's two entries are one wording, since it takes the
singular after a number.
singular after a number. Chinese has no singular, so both of its entries say the counted
noun between the number and the noun's name (`"{count} 个元件"`).
- **Chinese is a peer catalogue, not a copy of the Turkish one.** `ui/i18n_zh.py` and
`phrasebook_zh.py` hold the Simplified Chinese, keyed by the same English strings (and
the same guide templates) as the Turkish, so the Turkish can be rewritten without
touching it. `CATALOGUES` and the tests loop every language: each has its own stale-key
check, its own coverage check with its own `SAME_IN_BOTH` list (Chinese borrows many
technical words but still keeps the entry, so the catalogue scan sees the term), and its
own same-as-key list (only "3D" and "LED" -- any other entry equal to its English key is
an unfinished translation). Accelerators are compared on the letter, not its case
(`文件(&F)`), because Qt's `&` marks the key and the label above shows the capital. The
guide's `language`
argument takes `zh`, the page and JSON export are tagged `zh`, and a test builds the
NE555 example in Chinese and asks for a Chinese character in the page, so a catalogue
that stopped being reached fails rather than passing silently.
- **Home replaces the dialog, and imports nothing from the window** (`ui/home.py`). A
sidebar holds the doors and the places beside a page that scrolls. One primary door --
"Draw Your First Circuit" on a first start, "New Circuit" after -- with Open… under it and
Expand Down
8 changes: 4 additions & 4 deletions docs/MCP.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,10 @@ engine module and rasterised by Qt, so it works where `render_3d_view` cannot.
**Nothing writes to disk unless you name a path**, and the three tools that write files
hold to it in different ways. `generate_guide` without a directory returns the summary
and the warnings, which is usually the question being asked. It takes a `language` too —
`"en"` or `"tr"`, the language of whoever will build from it — and refuses one it cannot
write (`unknown-language`) rather than answering in English. `export_pdf` has no useful
answer without files, so without a directory it is refused (`no-directory`) rather than
writing two sheets into whatever directory the server was started in. `export_step` takes
`"en"`, `"tr"` or `"zh"`, the language of whoever will build from it — and refuses one it
cannot write (`unknown-language`) rather than answering in English. `export_pdf` has no
useful answer without files, so without a directory it is refused (`no-directory`) rather
than writing two sheets into whatever directory the server was started in. `export_step` takes
a file rather than a directory, adds `.step` if the name has neither `.step` nor `.stp`,
and is refused without one (`no-path`) for the same reason.

Expand Down
15 changes: 12 additions & 3 deletions src/perfboard_studio/phrasebook.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"""What the build guide says, in each language it can say it in.

Turkish is the table in this module; Chinese is ``phrasebook_zh.py``, the same shape in
its own file. Both follow the rules below.

The guide is the one piece of engine output a person follows with an iron in their hand,
and until this module it existed only in English while the window around it spoke
Turkish. It is translated HERE, in the engine, rather than by the interface's catalogue
Expand Down Expand Up @@ -40,11 +43,13 @@
from functools import cache
from typing import Literal, TypeAlias

from .phrasebook_zh import CHINESE

#: The languages a guide can be written in. A ``TypeAlias`` rather than a PEP 695 alias
#: because it is read at run time by ``get_args`` -- see CLAUDE.md on the others.
GuideLanguage: TypeAlias = Literal["en", "tr"] # noqa: UP040
GuideLanguage: TypeAlias = Literal["en", "tr", "zh"] # noqa: UP040

GUIDE_LANGUAGES: tuple[GuideLanguage, ...] = ("en", "tr")
GUIDE_LANGUAGES: tuple[GuideLanguage, ...] = ("en", "tr", "zh")


def guide_language(code: str | None) -> GuideLanguage:
Expand All @@ -54,6 +59,8 @@ def guide_language(code: str | None) -> GuideLanguage:
locale (``tr_TR``, ``tr-TR``), and a guide in English is a working guide.
"""
prefix = (code or "").replace("-", "_").split("_")[0].lower()
if prefix == "zh":
return "zh"
return "tr" if prefix == "tr" else "en"


Expand All @@ -69,7 +76,9 @@ class Phrasebook:

def __init__(self, language: GuideLanguage) -> None:
self.language: GuideLanguage = language
self._table: dict[str, str] = TURKISH if language == "tr" else {}
self._table: dict[str, str] = (
TURKISH if language == "tr" else CHINESE if language == "zh" else {}
)

def __call__(self, template: str, /, **fields: object) -> str:
text = self._table.get(template, template)
Expand Down
Loading