localization

Immutable message catalogs with locale fallback and named substitutions

Garnet Localization

Require garnet-localization to format dialogue or other text in a headless Crystal program. The shard has no dependencies.

require "garnet-localization"

messages = Garnet::Localization::Messages.new("en", {
  "en" => {"greeting" => "Welcome, {name}"},
  "fr" => {"greeting" => "Bienvenue, {name}"},
})
puts messages.format("fr-CA", "greeting", {"name" => "Ari"}) # Bienvenue, Ari

Lookup tries the requested locale and its parents, then the fallback locale and its parents. Missing keys and missing named arguments raise KeyError.

Repository

localization

Owner
Statistic
  • 0
  • 0
  • 0
  • 1
  • 0
  • 1 day ago
  • November 30, 2026
License

MIT License

Links
Synced at

Wed, 02 Dec 2026 02:09:46 GMT

Languages