Available in
Marketplaces, most starred first
Tags
Add to README
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Claude loads one when your task matches it, or you run it by name.
1 marketplace, most starred first
internationalization, i18n, localization, translations, go-intl, icu-messages, locale
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
A high-performance Go internationalization library with a simple API for sharing translations across terminal, desktop, and server applications.
go-intl is all gophers need
English | 简体中文
Pick a language once, then translate by key.
t := catalog.Translations("en")
t("Inbox.title") // "Inbox"
A Bubble Tea model, a Fyne or MyGo window, an NSGo view, a Wails app’s local Go backend, and an HTTP handler can each select a language from the same immutable catalog.
Use the go-intl CLI to extract, check and merge translation catalogs.
Apple M3 Pro, Go 1.27.1 (darwin/arm64). The ten interpolation cases use medians from the six-run v0.1.1 comparison. The two static lookups and the English plural retain the original three-run medians. Each cell reports ns/op · B/op · allocs/op. Speedup and memory ratio are go-i18n divided by go-intl for ns/op and B/op, respectively. A dash (—) means both libraries allocate zero.
v0.1.1 benchmark results · Original benchmarks and methodology
The core package requires Go 1.25 or later. To try the example in a new module, run the commands below. In an existing Go module, run just the go get command.
mkdir intl-demo
cd intl-demo
go mod init example.com/intl-demo
go get github.com/waterkyuu/go-intl
Save this program as main.go in the demo module and run go run .. The import path ends in go-intl and the package name is intl.
package main
import (
"fmt"
"log"
"github.com/waterkyuu/go-intl"
)
func main() {
catalog, err := intl.New("en",
intl.Define("en", map[string]string{
"Inbox.title": "Inbox",
"Inbox.hello": "Hello, {name}!",
"Inbox.count": "{n, plural, =0 {No unread messages} one {# unread message} other {# unread messages}}",
"Inbox.state": "{online, select, true {Online} other {Offline}}",
}),
intl.Define("fr", map[string]string{
"Inbox.title": "Boîte de réception",
}),
)
if err != nil {
log.Fatal(err)
}
t := catalog.Translations("en", "Inbox")
fmt.Println(t("title")) // Inbox
fmt.Println(t("hello", intl.Values{"name": "Ada"})) // Hello, Ada!
fmt.Println(t("count", intl.Values{"n": 2})) // 2 unread messages
fmt.Println(t("state", intl.Values{"online": true})) // Online
}
To omit the namespace, pass the full key. This example uses the same catalog:
fr := catalog.Translations("fr")
fmt.Println(fr("Inbox.title")) // Boîte de réception
fmt.Println(fr("Inbox.count", intl.Values{"n": 2})) // 2 unread messages
The first argument to intl.New sets the fallback language. Here, "en" supplies the missing French translation for Inbox.count. To change the fallback, pass the desired language tag and include a source for that language.
Put native definitions in ordinary .go files with intl.Define. The function snapshots the map. Load data files from disk or embed them in the application binary. Each filename's stem is its BCP 47 language tag, such as fr-CA.toml. Multiple files for one language can contribute disjoint keys.
Place locales/en.json next to this Go file, then add more locales to the directory as needed.
package translations
import (
"embed"
"github.com/waterkyuu/go-intl"
)
//go:embed locales/*
var files embed.FS
// Load compiles the embedded translations at application startup.
func Load() (*intl.Catalog, error) {
sources, err := intl.LoadFS(files, "locales/*")
if err != nil {
return nil, err
}
return intl.New("en", sources...)
}
| Source | Example defining the same key |
|---|---|
| Go | intl.Define("en", map[string]string{"Inbox.title": "Inbox"}) |
| JSON | {"Inbox": {"title": "Inbox"}} |
| TOML | Inbox.title = "Inbox" |
| YAML | Inbox: {title: Inbox} |
| CSV | Header key,message, followed by a row Inbox.title,Inbox |
JSON, TOML and YAML also accept dotted string keys. CSV supports quoted commas and multiline messages. Empty translations are valid. File decoding errors identify the file. Catalog construction reports the locale, key and source for invalid patterns and overlapping definitions.
Built from public signals: copy clicks on this site, GitHub stars and activity, the README and the manifest. Not a security audit or an endorsement.
npx claudepluginhub waterkyuu/go-intl --plugin go-intlPlugins from other owners that cover similar ground