Writing in Your Language

LokaScript lets you write hyperscript commands in 24 languages.
The runtime translates your code to English before execution —
your existing English code continues to work unchanged.

Supported Languages

LokaScript supports three word-order families:

Word Order Languages
SVO (Subject-Verb-Object) English, Spanish, Portuguese, French, German, Italian, Indonesian, Chinese, Swahili, Malay
SOV (Subject-Object-Verb) Japanese, Korean, Turkish, Hindi, Bengali, Quechua
VSO (Verb-Subject-Object) Arabic, Hebrew

Additional languages: Polish, Russian, Ukrainian, Thai, Tagalog, Vietnamese

How to Specify Language

Language is resolved in priority order:

1. Per-element with data-lang

<button _="on click alternar .active" data-lang="es">
  Spanish toggle
</button>

2. Inherited with data-hyperscript-lang

All children inherit the language:

<div data-hyperscript-lang="ja">
  <button _="on click .active を 切り替え">Toggle</button>
  <button _="on click .highlight を 追加">Add</button>
</div>

3. Document-level with <html lang>

<html lang="fr">
  <!-- All hyperscript on this page defaults to French -->
  <button _="on click basculer .active">Basculer</button>
</html>

English (en) and unresolved languages pass through without
translation.

The Same Command in Different Languages

Toggle (the most common command)

-- English (SVO): verb object
on click toggle .active

-- Spanish (SVO): verb object
on click alternar .active

-- Japanese (SOV): object particle verb
on click .active を 切り替え

-- Korean (SOV): object particle verb
on click .active 을 토글

-- Arabic (VSO): verb object
on click بدّل .active

Notice how SVO languages keep verb-then-object order, while
SOV languages put the object before the verb with a particle
marker.

Add with a target

-- English
on click add .highlight to #box

-- French
on click ajouter .highlight sur #box

-- Japanese
on click #box に .highlight を 追加

-- Korean
on click #box 에 .highlight 을 추가

Put text into an element

-- English
on click put "Hello" into #output

-- Spanish
on click poner "Hola" en #output

-- Japanese
on click "Hello" を #output に 置く

-- French
on click mettre "Bonjour" sur #output

What Translates and What Stays in English

Translates:

  • Command keywords: toggle, add, remove, put, set, etc.
  • Prepositions/particles: on, into, from, to
  • References: me, my, it
  • Logical keywords: if, then, else, and, or

Stays in English:

  • CSS selectors: .active, #count, .my-class
  • HTML attributes: innerHTML, value, disabled
  • JavaScript operators: >, +, ==
  • String literals: "Hello"
  • Numbers: 5, 300
  • Feature keywords: def, worker (use English for these)

Compound Commands

Chain commands with then (or its translated equivalent):

-- English
on click add .highlight to #box then put "Done!" into #msg

-- Spanish
on click agregar .highlight en #box then poner "Listo!" en #msg

Next Steps