Skip to content

Commit f79b99f

Browse files
author
PyCompiler ARK++ Team
committed
ci(pre-commit): add pbr to bandit additional_dependencies and rebuild hook env
1 parent 6438cbb commit f79b99f

2 files changed

Lines changed: 83 additions & 8 deletions

File tree

docs/about_sdks.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Table of Contents
3535

3636
---
3737

38-
1) Engine SDK — Capabilities
38+
## 1) Engine SDK — Capabilities {#1-engine-sdk--capabilities}
3939

4040
1.1 Overview and Versioning
4141
- Purpose: stable façade for third‑party build engines to integrate with the GUI.
@@ -125,7 +125,7 @@ if vroot:
125125

126126
---
127127

128-
2) API_SDK — Capabilities
128+
## 2) API_SDK — Capabilities {#2-api_sdk--capabilities}
129129

130130
2.1 Overview, Versioning & get_capabilities
131131
- Purpose: modular kit for API plugins. Supports both BCASL (pre‑compile) and ACASL (post‑compile).
@@ -279,7 +279,7 @@ def acasl_run(ctx):
279279

280280
---
281281

282-
Appendix: Capability Matrix (Quick Glance)
282+
## Appendix: Capability Matrix (Quick Glance) {#appendix-capability-matrix-quick-glance}
283283

284284
Engine SDK
285285
- Process: QProcess/subprocess, callbacks, timeouts
@@ -297,7 +297,7 @@ API_SDK (BCASL + ACASL)
297297
- Bridges & Facades: plugin decorator (BCASL), wrap_context (BCASL), wrap_post_context (ACASL), set_selected_workspace; namespaced facades BCASL_SDK and ACASL_SDK
298298

299299
For more context and step‑by‑step tutorials, see:
300-
- Engines how‑to: docs/how_to_creat_a_building_engine.md
301-
- BCASL plugins how‑to: docs/how_to_creat_a_bcasl_API.md
302-
- ACASL plugins how‑to: docs/how_to_creat_a_acasl_API.md
300+
- Engines how‑to: docs/how_to_create_a_building_engine.md
301+
- BCASL plugins how‑to: docs/how_to_create_a_bcasl_API.md
302+
- ACASL plugins how‑to: docs/how_to_create_an_acasl_API.md
303303
- Framework Reference: docs/REFERENCE.md

docs/how_to_create_a_bcasl_API.md

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,86 @@ if not ok:
305305

306306
## 8) i18n (async) {#8-i18n-async}
307307

308-
- Place a languages/ folder in your package; load with API_SDK helpers:
308+
Goal
309+
- Ship a languages/ folder with your plugin so UI strings are localized.
310+
- Load translations at runtime with the SDK helper and always provide safe English fallbacks.
311+
- Use string placeholders and tr.get(...) consistently, as illustrated in API/cleaner.
312+
313+
Folder layout
314+
```
315+
API/
316+
└── my_plugin/
317+
├── __init__.py
318+
└── languages/
319+
├── en.json
320+
├── fr.json
321+
├── es.json
322+
└── de.json
323+
```
324+
325+
Minimal en.json (example keys)
326+
```json
327+
{
328+
"_meta": { "code": "en", "name": "English" },
329+
"title": "MyPlugin",
330+
"start": "Starting {plugin}…",
331+
"done": "Done",
332+
"confirm_run": "Run this step now?",
333+
"canceled": "Canceled by user",
334+
"error_fmt": "Error: {error}"
335+
}
336+
```
337+
338+
Loading translations (async helper)
309339
```python
310340
import asyncio
311341
from API_SDK.BCASL_SDK import load_plugin_translations
312-
tr = asyncio.run(load_plugin_translations(__file__, "System"))
342+
343+
# Language can be a code ("en", "fr" …) or "System" for auto-detection
344+
tr = asyncio.run(load_plugin_translations(__file__, "System")) or {}
345+
```
346+
347+
Using translations with robust fallbacks and placeholders
348+
```python
349+
# Always provide an English fallback when using tr.get
350+
sctx.log_info(tr.get("start", "Starting {plugin}").format(plugin=BCASL_NAME))
351+
352+
# Guarded prompt (respect non-interactive mode)
353+
noninteractive = bool(getattr(sctx, "noninteractive", False) or getattr(sctx, "is_noninteractive", False))
354+
if (not noninteractive):
355+
if not sctx.msg_question(tr.get("title", BCASL_NAME), tr.get("confirm_run", "Run this step now?"), default_yes=False):
356+
sctx.log_warn(tr.get("canceled", "Canceled by user"))
357+
return
358+
359+
# Formatting example for errors
360+
try:
361+
...
362+
except Exception as e:
363+
sctx.log_warn(tr.get("error_fmt", "Error: {error}").format(error=e))
364+
```
365+
366+
Keys and conventions (inspired by API/cleaner)
367+
- Use explicit, short keys: title, confirm_*, progress_*, *_fmt for formatted messages.
368+
- Keep placeholders explicit and named (e.g., {file}, {error}, {current}, {total}).
369+
- Provide a complete en.json as the baseline and add locales incrementally (fr, es, de …).
370+
- For progress handles, update text with translated strings and placeholders:
371+
- tr.get("deleting_pyc", "Deleting .pyc ({current}/{total})").format(current=i, total=n)
372+
373+
Best practices
374+
- Do not block UI for i18n; loading JSON is local I/O.
375+
- Normalize the language via the SDK helper (System auto-detect). Keep values UTF-8.
376+
- Keep English as the code fallback when a key is missing.
377+
- Avoid string concatenation; prefer .format with named placeholders.
378+
379+
Complete pattern (typical flow)
380+
```python
381+
from API_SDK.BCASL_SDK import progress
382+
tr = asyncio.run(load_plugin_translations(__file__, "System")) or {}
383+
384+
with progress(tr.get("title", BCASL_NAME), tr.get("start", "Starting {plugin}").format(plugin=BCASL_NAME), maximum=1) as ph:
385+
# … work …
386+
ph.update(1, tr.get("done", "Done"))
387+
sctx.log_info(tr.get("done", "Done"))
313388
```
314389

315390
---

0 commit comments

Comments
 (0)