@lokascript/hyperscript-adapter 2.0.0 → 2.2.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.
- package/README.md +46 -3
- package/dist/hyperscript-i18n-ar.global.js +4 -4
- package/dist/hyperscript-i18n-bn.global.js +4 -4
- package/dist/hyperscript-i18n-de.global.js +4 -4
- package/dist/hyperscript-i18n-east-asian.global.js +4 -4
- package/dist/hyperscript-i18n-en.global.js +6 -6
- package/dist/hyperscript-i18n-es.global.js +4 -4
- package/dist/hyperscript-i18n-fr.global.js +4 -4
- package/dist/hyperscript-i18n-he.global.js +4 -4
- package/dist/hyperscript-i18n-hi.global.js +4 -4
- package/dist/hyperscript-i18n-id.global.js +4 -4
- package/dist/hyperscript-i18n-it.global.js +4 -4
- package/dist/hyperscript-i18n-ja.global.js +4 -4
- package/dist/hyperscript-i18n-ko.global.js +4 -4
- package/dist/hyperscript-i18n-ms.global.js +4 -4
- package/dist/hyperscript-i18n-pl.global.js +4 -4
- package/dist/hyperscript-i18n-pt.global.js +4 -4
- package/dist/hyperscript-i18n-qu.global.js +4 -4
- package/dist/hyperscript-i18n-ru.global.js +4 -4
- package/dist/hyperscript-i18n-slavic.global.js +4 -4
- package/dist/hyperscript-i18n-south-asian.global.js +4 -4
- package/dist/hyperscript-i18n-southeast-asian.global.js +4 -4
- package/dist/hyperscript-i18n-sw.global.js +4 -4
- package/dist/hyperscript-i18n-th.global.js +4 -4
- package/dist/hyperscript-i18n-tl.global.js +4 -4
- package/dist/hyperscript-i18n-tr.global.js +4 -4
- package/dist/hyperscript-i18n-uk.global.js +4 -4
- package/dist/hyperscript-i18n-vi.global.js +4 -4
- package/dist/hyperscript-i18n-western.global.js +4 -4
- package/dist/hyperscript-i18n-zh.global.js +4 -4
- package/dist/hyperscript-i18n.global.js +73 -7
- package/dist/hyperscript-i18n.global.js.map +1 -1
- package/package.json +1 -1
- 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
|
|
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="
|
|
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
|
+
```
|