Skip to content

dAppCore/go-i18n

Repository files navigation

Go Reference License: EUPL-1.2 Go Version

go-i18n

Grammar engine for Go. Provides forward composition primitives (PastTense, Gerund, Pluralize, Article, composite progress and label functions), a T() translation entry point with namespace key handlers, and a reversal engine that recovers base forms and grammatical roles from inflected text. The reversal package produces GrammarImprint feature vectors for semantic similarity scoring, builds reference domain distributions, performs anomaly detection, and includes a 1B model pre-sort pipeline for training data classification. Consumers bring their own translation keys; this library provides the grammatical machinery.

Bundled locales — all 24 official EU languages: en (the English of England — bare en IS en-GB), bg, cs, da, de, el, es, et, fi, fr, ga, hr, hu, it, lt, lv, mt, nl, pl, pt, ro, sk, sl, sv — plus en-US (dialect override). Every locale composes full output from the same English keys through the gram.word bridge: T("i18n.done.delete", "file") → "File deleted" / "Fichier supprimé" / "Datei gelöscht" / "Plik usunięty" / "Файл изтрит" / "Tiedosto poistettu" / "Failas ištrintas" / "Fajl imħassar". No language-specific code exists in the engine — every grammar (suffixed definites, assimilating articles, noun lenition, numeral-governed singulars, three-gender participle agreement) is declared as locale data.

The phonetics package gives the engine an ear: the vendored CMU Pronouncing Dictionary (134k words with stress markers) backs Article() and consonant doubling with actual phonemes ("an yttrium sample", commit → committed but visit → visited by stress, not by table), plus rhyme, alliteration, syllable and stress primitives, metre scanning (ScanLine → dominant foot + regularity), and whole-sentence transcription in ARPABET, IPA or readable phonetic respelling.

Novelty locales double as architecture proofs: en-x-pirate (vocabulary-only dialect riding the en fallback chain — "Blimey! Couldn't heave plank"), tlh (Klingon: canonical Okrand vocabulary, aspect suffixes filling the past/gerund slots mechanically, and the article.none mechanism article-less languages like Japanese and Russian will reuse — "De' teqpu'") and la (Latin: subject + perfect passive participle IS lapidary Latin — "Tabula deleta", "Erratum inventum" — the Progress form is the gerundive in Cato's register ("Delenda..."), three-gender participle agreement, and the noun table closes the loop on English's own irregular plurals: errata, data, opera, indices, genera).

Module: dappco.re/go/i18n Licence: EUPL-1.2 Language: Go 1.26

Quick Start

import "dappco.re/go/i18n"

// Grammar primitives
fmt.Println(i18n.PastTense("delete"))   // "deleted"
fmt.Println(i18n.Gerund("build"))       // "building"
fmt.Println(i18n.Pluralize("file", 3))  // "files"

// Translation with auto-composed output
fmt.Println(i18n.T("i18n.progress.build"))  // "Building..."
fmt.Println(i18n.T("i18n.done.delete", "file"))  // "File deleted"

// Reversal: recover grammar from text
tokeniser := reversal.NewTokeniser()
tokens := tokeniser.Tokenise("deleted the files")
imprint := reversal.NewImprint(tokens)

Documentation

  • Architecture — grammar primitives, T() handlers, reversal engine, GrammarImprint, reference distributions, 1B pipeline
  • Development Guide — building, testing, grammar table structure (critical: do not flatten JSON)
  • Project History — completed phases and known limitations

Build & Test

go test ./...
go test -v ./reversal/
go test -bench=. ./...
go build ./...

For repeatable local runs in a clean workspace, the repo also ships a Makefile with the standard workflow targets:

make build
make vet
make test
make cover
make tidy

Licence

European Union Public Licence 1.2 — see LICENCE for details.

About

Core ecosystem — go-i18n

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages