Tifinagh ↔ Latin script converter for the Amazigh (Tamazight) language — supports informal input aliases, auto-detection, and regional variants
# tifinagh-convert
## Why
Amazigh (Tamazight) remains one of the most under-resourced languages
in NLP and software. Developers building Tifinagh-aware tools — OCR
pipelines, keyboards, dictionaries — have had to re-implement the same
script conversion logic from scratch. This package is the shared
infrastructure that should have existed.
> Tifinagh ↔ Latin script converter for the Amazigh (Tamazight) language.
Zero dependencies. TypeScript-first. Based on the official IRCAM Neo-Tifinagh standard
and the ALA-LC / BGN-PCGN romanization tables.
```bash
npm install tifinagh-convert
```
---
## Quick start
```ts
import { convert, detect, alphabet } from 'tifinagh-convert'
// Tifinagh → Latin
const r1 = convert('ⵜⴰⵎⵓⵔⵜ', { to: 'latin' })
console.log(r1.output) // 'tamurt'
// Latin → Tifinagh
const r2 = convert('tamurt', { from: 'latin', to: 'tifinagh' })
console.log(r2.output) // 'ⵜⴰⵎⵓⵔⵜ'
// Auto-detect source script
const r3 = convert('ⵎⵓⵔ', { to: 'latin' })
console.log(r3.output) // 'mur'
```
---
## API
### `convert(text, options)`
| Option | Type | Default | Description |
|----------|--------------------------|--------------|------------------------------------|
| `to` | `'tifinagh' \| 'latin'` | **required** | Target script |
| `from` | `'tifinagh' \| 'latin'` | auto-detect | Source script (optional) |
| `region` | `'morocco' \| 'algeria'` | `'morocco'` | Affects letter inventory |
Returns `ConvertResult`:
```ts
{
output: string // converted text
from: Script
to: Script
region: Region
detected: boolean // true if script was auto-detected
warnings: ConversionWarning[] // ambiguous or unknown characters
}
```
Each warning:
```ts
{
code: 'AMBIGUOUS_DIGRAPH' | 'UNKNOWN_CHAR' | 'APPROXIMATED_CHAR'
message: string
position: number // zero-based index in the input string
}
```
---
### `detect(text)`
Auto …