lisan-compiler

raw JSON →
0.1.1 verified Fri May 01 auth: no javascript

Lisan Compiler v0.1.1 compiles Translation objects into Dictionary objects for the Lisan i18n library. It provides functions like parseLisanLiteral, parse, and generate. Designed as a build-time tool (devDependency) to precompile translations, reducing runtime overhead. The library is TypeScript-friendly, ships type definitions, and supports UMD browser usage via CDN. Lisan focuses on minimal bundle size and performance. Compiler handles Lisan Literal syntax and converts it to optimized dictionary format.

error TypeError: translations.map is not a function
cause Passing a single translation object without an array where an array is expected.
fix
Wrap the object in an array: parse([translations]) instead of parse(translations).
error Cannot find module 'lisan-compiler'
cause Installed as devDependency but trying to use in runtime code.
fix
Move lisan-compiler to dependencies if needed, or use it in build scripts only.
gotcha parse and generate are separate steps; calling generate on raw translations will throw.
fix Always call parse() first, then generate().
deprecated The UMD global is lisanCompiler, not lisanCompiler. Default export behavior differs between builds.
fix Access named exports via window.lisanCompiler in UMD.
gotcha parseLisanLiteral expects a single Lisan Literal string, not full translations object.
fix Use parse() for objects, parseLisanLiteral() for individual literals.
npm install lisan-compiler
yarn add lisan-compiler
pnpm add lisan-compiler

Compiles a translations object into a Lisan dictionary using parse and generate.

import { parse, generate } from 'lisan-compiler';

const translations = {
  greeting: 'Hello, {name}!',
  farewell: { default: 'Goodbye', evening: 'Good night' },
};

const dictionary = generate(parse(translations));
console.log(dictionary);
// Output:
// {
//   greeting: { t: 'Hello, {name}!', p: ['name'] },
//   farewell: { t: { default: 'Goodbye', evening: 'Good night' }, p: [] }
// }