@lokascript/hyperscript-adapter 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +46 -3
  2. package/dist/hyperscript-i18n-ar.global.js +4 -4
  3. package/dist/hyperscript-i18n-bn.global.js +4 -4
  4. package/dist/hyperscript-i18n-de.global.js +4 -4
  5. package/dist/hyperscript-i18n-east-asian.global.js +4 -4
  6. package/dist/hyperscript-i18n-en.global.js +6 -6
  7. package/dist/hyperscript-i18n-es.global.js +4 -4
  8. package/dist/hyperscript-i18n-fr.global.js +4 -4
  9. package/dist/hyperscript-i18n-he.global.js +4 -4
  10. package/dist/hyperscript-i18n-hi.global.js +4 -4
  11. package/dist/hyperscript-i18n-id.global.js +4 -4
  12. package/dist/hyperscript-i18n-it.global.js +4 -4
  13. package/dist/hyperscript-i18n-ja.global.js +4 -4
  14. package/dist/hyperscript-i18n-ko.global.js +4 -4
  15. package/dist/hyperscript-i18n-ms.global.js +4 -4
  16. package/dist/hyperscript-i18n-pl.global.js +4 -4
  17. package/dist/hyperscript-i18n-pt.global.js +4 -4
  18. package/dist/hyperscript-i18n-qu.global.js +4 -4
  19. package/dist/hyperscript-i18n-ru.global.js +4 -4
  20. package/dist/hyperscript-i18n-slavic.global.js +4 -4
  21. package/dist/hyperscript-i18n-south-asian.global.js +4 -4
  22. package/dist/hyperscript-i18n-southeast-asian.global.js +4 -4
  23. package/dist/hyperscript-i18n-sw.global.js +4 -4
  24. package/dist/hyperscript-i18n-th.global.js +4 -4
  25. package/dist/hyperscript-i18n-tl.global.js +4 -4
  26. package/dist/hyperscript-i18n-tr.global.js +4 -4
  27. package/dist/hyperscript-i18n-uk.global.js +4 -4
  28. package/dist/hyperscript-i18n-vi.global.js +4 -4
  29. package/dist/hyperscript-i18n-western.global.js +4 -4
  30. package/dist/hyperscript-i18n-zh.global.js +4 -4
  31. package/dist/hyperscript-i18n.global.js +59 -7
  32. package/dist/hyperscript-i18n.global.js.map +1 -1
  33. package/package.json +1 -1
  34. package/src/hyperscript-renderer.ts +3 -0
package/README.md CHANGED
@@ -1,14 +1,22 @@
1
1
  # @lokascript/hyperscript-adapter
2
2
 
3
- Multilingual plugin for the original [\_hyperscript](https://hyperscript.org). Write hyperscript in any of 24 languages — the adapter translates to English before the standard parser runs.
3
+ Multilingual plugin for the original [\_hyperscript](https://hyperscript.org). Write hyperscript in any of 24 languages — the adapter translates to hyperscript code before the standard parser runs.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @lokascript/hyperscript-adapter
9
+ ```
10
+
11
+ Or use a CDN — see [Browser](#browser) below.
4
12
 
5
13
  ## Quick Start
6
14
 
7
15
  ### Browser
8
16
 
9
17
  ```html
10
- <script src="_hyperscript.js"></script>
11
- <script src="hyperscript-i18n-es.global.js"></script>
18
+ <script src="https://unpkg.com/hyperscript.org"></script>
19
+ <script src="https://unpkg.com/@lokascript/hyperscript-adapter@2/dist/hyperscript-i18n-es.global.js"></script>
12
20
 
13
21
  <!-- Spanish -->
14
22
  <button _="on click alternar .active on me" data-lang="es">Toggle</button>
@@ -24,6 +32,8 @@ Multilingual plugin for the original [\_hyperscript](https://hyperscript.org). W
24
32
 
25
33
  The plugin auto-registers when `_hyperscript` is available. No extra JS needed.
26
34
 
35
+ See the [live demo](https://lokascript-docs.fly.dev/multilingual-plugin/) for interactive examples.
36
+
27
37
  ### Node.js / Bundlers
28
38
 
29
39
  ```javascript
@@ -145,3 +155,36 @@ The plugin overrides `runtime.getScript()` — the method \_hyperscript calls to
145
155
  - **Feature declarations** (`def`, `worker`): these are original \_hyperscript feature-level keywords that are not part of the adapter's translation layer — keep them in English. Command bodies within features translate normally. (`behavior` IS supported.)
146
156
  - **SOV/VSO accuracy**: Japanese, Korean, Turkish have lower pattern coverage — confidence gating may trigger fallback to the original text
147
157
  - **Programmatic calls**: `_hyperscript("code")` bypasses the plugin; use `preprocess()` for those
158
+
159
+ ## Troubleshooting
160
+
161
+ **"Translation unchanged" warning in console**
162
+
163
+ The adapter logs this when it receives non-English text but produces no change. Common causes:
164
+
165
+ - Wrong language code — check the `data-lang` attribute matches a supported language (e.g. `es`, not `spa`)
166
+ - Unsupported command — only commands with semantic patterns translate (toggle, add, remove, put, set, etc.). Feature-level keywords (`def`, `worker`) stay in English.
167
+ - Missing language bundle — if using a single-language bundle, only that language translates. Other languages pass through unchanged.
168
+
169
+ **SOV languages (ja, ko, tr) not translating reliably**
170
+
171
+ These languages produce lower confidence scores due to word-order differences. Lower the threshold with a per-language map:
172
+
173
+ ```javascript
174
+ _hyperscript.use(
175
+ hyperscriptI18n({
176
+ confidenceThreshold: { ja: 0.1, ko: 0.05, tr: 0.1, '*': 0.5 },
177
+ })
178
+ );
179
+ ```
180
+
181
+ **`_hyperscript("code")` calls not translating**
182
+
183
+ The plugin only intercepts `_="..."` attributes in the DOM. For programmatic calls, use `preprocess()`:
184
+
185
+ ```javascript
186
+ import { preprocess } from '@lokascript/hyperscript-adapter';
187
+
188
+ const english = preprocess('alternar .active', 'es');
189
+ _hyperscript(english);
190
+ ```