@skidy89/lang
v0.1.18
Published
language loader for node.js using rust!
Maintainers
Readme
@skidy89/lang - simple language loader (SLL)
A lightweight Node.js package that provides a native N-API addon built with Rust and TypeScript type definitions for loading and parsing .lang files.
This module enables developers to manage multilingual applications by loading key-value pairs from .lang files stored in a specified directory.
Table of Contents
- Installation
- Usage
- Example .lang File
- Building the Package
- Publishing to npm
- Package Contents
- Troubleshooting
- License
- Notes
Installation
Install the package via npm:
npm install @skidy89/langEnsure you have Node.js (version 12 or higher) installed, as this package relies on N-API for native module support.
usage
Load and parse .lang files using the native SSL class:
import { SSL } from '@skidy89/lang';
const cli = new SSL('./languages');
async function loadLanguages() {
try {
const langData = await cli.load();
console.log(langData['es']['hello-world']); // Outputs: "hello world!!"
} catch (err) {
console.error('Error loading languages:', err);
}
}
loadLanguages();example lang file!
Create .lang files in your specified directory (e.g., ./languages/es.lang). The format supports key-value pairs with # for comments!
# this is ignored, write whatever you want!!
hello-world = "¡Hola mundo!"
welcome = "Bienvenido"Files must have the .lang extension. Keys and values are separated by =. Comments start with #.
Building the Package and benchmarks
[!WARNING] work in progress
