Multilingual Plugin for _hyperscript

Add multilingual support to existing _hyperscript projects. Write behaviors in Spanish, Japanese, Arabic, and 21 more languages — no migration required.

Already using LokaScript? You don't need this plugin — multilingual support is built in. This page is for projects using the original _hyperscript.

Quick Start

<!-- 1. Load _hyperscript -->
<script src="https://unpkg.com/hyperscript.org"></script>

<!-- 2. Load the multilingual plugin (Spanish) -->
<script src="https://unpkg.com/@lokascript/hyperscript-adapter@2.10.0/dist/hyperscript-i18n-es.global.js"></script>

<!-- 3. Write hyperscript in Spanish -->
<button _="on click alternar .active" data-lang="es">
  Haz clic
</button>

The plugin patches _hyperscript at runtime — your existing English code continues to work unchanged.

Or install via npm:

npm install @lokascript/hyperscript-adapter

Live Demos

Each button below uses non-English _hyperscript with a data-lang attribute. The plugin translates the command to canonical _hyperscript before the runtime parses it.

The demo runs in an isolated frame loading the real hyperscript.org runtime plus the plugin — this page itself loads @hyperfixi/core (a different, LokaScript-native engine) for its own docs tooling, and the two would conflict if run side by side over the same page.

The snippets running in the frame above.
LanguageWord orderSnippet
Spanish ESSVO_="on click alternar .active" data-lang="es"
Japanese JASOV_="on click .active を 切り替え" data-lang="ja"
Korean KOSOV_="on click .active 을 토글" data-lang="ko"
French — add FRSVO_="on click ajouter .highlight sur #frBox" data-lang="fr"
Spanish — put ESSVO_='on click poner "Hola desde _hyperscript!" en #pluginMsg' data-lang="es"
Spanish — remove ESSVO_="on click quitar .highlight de #rmBox" data-lang="es"
German — show / hide DESVO_="on click verbergen #dePanel" data-lang="de"
_="on click zeigen #dePanel" data-lang="de"
Arabic — put ARVSO_='on click ضع "مرحبا بالعالم!" في #arOut' data-lang="ar"
Portuguese — take PTSVO_="on click pegar .active de .pt-tab for me" data-lang="pt"
Chinese — put ZHSVO_="on click 放 '<div>新项目</div>' 到 #zhList" data-lang="zh"
Indonesian — send IDSVO_="on click kirim greet ke #idReceiver" data-lang="id"

Choose a Bundle

Bundle Size (gzipped) Languages
hyperscript-i18n-es.global.js 66–69 KB One language. 23 to choose from: ar bn de es fr he hi id it ja ko ms pl pt qu ru sw th tl tr uk vi zh
hyperscript-i18n-western.global.js 76 KB Spanish, Portuguese, French, German
hyperscript-i18n-east-asian.global.js 76 KB Japanese, Korean, Chinese
hyperscript-i18n-slavic.global.js 77 KB Polish, Russian, Ukrainian
hyperscript-i18n-south-asian.global.js 70 KB Bengali, Hindi
hyperscript-i18n-southeast-asian.global.js 75 KB Indonesian, Malay, Thai, Tagalog, Vietnamese
hyperscript-i18n.global.js 197 KB All 24 languages
hyperscript-i18n-lite.global.js ~1 KB None (requires @lokascript/semantic loaded separately)

Sizes are gzipped transfer size, measured against the published
@lokascript/hyperscript-adapter@2.10.0. A
single-language bundle is the cheapest way in; the regional bundles cost
only a few KB more than one language, so reach for one as soon as you
need two.

Most projects only need a single-language bundle.

Configuration

For browser usage with <script> tags, the plugin auto-registers with sensible defaults — no configuration needed.

For Node.js or bundler projects, pass options to hyperscriptI18n():

import { hyperscriptI18n } from '@lokascript/hyperscript-adapter';

_hyperscript.use(
  hyperscriptI18n({
    // Set a default language for all elements
    defaultLanguage: 'es',

    // Enable console logging during development
    debug: true,

    // Tune confidence per language — SOV languages
    // (ja, ko, tr) need lower thresholds
    confidenceThreshold: {
      es: 0.7,
      ja: 0.1,
      ko: 0.05,
      '*': 0.5,   // default for unlisted languages
    },
  })
);

See the API reference for the full options table.

Plugin vs LokaScript

Use the Plugin When

  • You already have _hyperscript in production
  • You want to add one or a few languages
  • You prefer the original _hyperscript runtime
  • You need a drop-in addition with no migration

Use LokaScript When

  • You're starting a new project
  • You want tree-shakeable bundles (2.0 KB–309.1 KB gzipped)
  • You need the full 59-command set with native multilingual
  • You want the Vite plugin and build tooling