You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/how_to_create_a_BC_plugin.md
+53-6Lines changed: 53 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -76,22 +76,66 @@ PLUGIN = MyPlugin()
76
76
77
77
## 4) Internationalization
78
78
79
-
- Place JSON translation files under `languages/`
79
+
BCASL supports plugin‑local i18n files and a lightweight synchronization API so your plugin updates its texts automatically when the app language changes or when using the BCASL only_mod Studio.
80
+
81
+
- Place JSON translation files under `languages/` in your plugin package
80
82
- Always include `en.json` as the fallback
81
-
- Use `apply_i18n(gui, tr)` in your plugin to update UI if any is exposed
83
+
- Implement `apply_i18n(gui, tr)` in your plugin; it will be called with a translation dict
84
+
- Register your plugin instance for i18n so that synchronization can target it
85
+
- Optionally expose your package directory so the sync layer can auto‑discover your languages folder
82
86
83
87
Example `languages/en.json`:
84
88
```json
85
89
{
86
90
"_meta": {"code": "en", "name": "English"},
87
-
"title": "My BC Plugin",
88
-
"question": "Proceed with pre‑build checks?"
91
+
"myplugin_title": "My BC Plugin",
92
+
"myplugin_question": "Proceed with pre‑build checks?"
89
93
}
90
94
```
91
95
96
+
Example `__init__.py` snippets:
97
+
```python
98
+
from pathlib import Path
99
+
from Plugins_SDK.GeneralContext.i18n import register_instance
0 commit comments