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.
- Installation
- Usage
- Example .lang File
- Building the Package
- Publishing to npm
- Package Contents
- Troubleshooting
- License
- Notes
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.
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();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 #.
Warning
work in progress