crababel
Version, currently 0.3.04 versions
- 0.3.1latestOct 5, 2026
- 0.3.0Sep 26, 2026
- 0.2.0Jun 30, 2026
- 0.1.0not indexedJun 30, 2026
github.com/sbsoftware/crababel
No description declared in shard.yml.
Installation
# Add this to your shard.yml
dependencies:
crababel:
github: sbsoftware/crababel
version: ~> 0.3.0Then run:
shards installshard.yml
- Crystal
>= 1.18.2- License
- MIT
- Author
- Stefan Bilharz
Dependencies
Runtime Dependencies
- crygen*github: tamdaz/crygen
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
crababel
TODO: Write a description here
Installation
-
Add the dependency to your
shard.yml:dependencies: crababel: github: your-github-user/crababel -
Run
shards install
Usage
require "crababel"
Translations are generated at compile time from shard defaults in lib/**/config/locales/**/*.yml and project translations in config/locales/**/*.yml, then exposed as methods on the locale module. Shard locale files are scanned first in sorted path order, then project locale files are merged last in sorted path order and override shard defaults on identical keys. A single project file such as config/locales/en.yml still works, and larger projects can split translations by domain:
# config/locales/en.yml
en:
greeting: "Hello"
# config/locales/errors.yml
en:
errors:
not_found: "Not found"
Crababel.locales # => ["en", "de"]
Crababel.locale("en").greeting # => "Hello"
Crababel.locale("de").errors.not_found # => "Nicht gefunden"
Locale files are loaded in sorted path order so generated code is deterministic. Files are deep-merged by namespace, but each full translation key may be defined only once within an individual shard or the project group. Crababel raises at compile time for those conflicts while allowing project keys to replace shard defaults. If sibling shards define the same key, the later sorted shard silently takes precedence.
The locale roots in the project's own files define the supported locales returned by Crababel.locales and accepted by Crababel.locale. Locale modules supplied only by dependencies are still generated, but are not advertised. When the project has no locale roots, Crababel supports only the locale roots shared by every dependency; if dependencies have no locale in common, generation fails with guidance to declare the project's supported roots explicitly.
Placeholder interpolation
Crababel generates method arguments for placeholders written as Crystal interpolation expressions. Each unique #{name} placeholder becomes a required String argument, and repeated placeholders reuse the same argument.
For example:
en:
welcome_user: "Hello #{name}"
route: "From #{origin} to #{destination}"
Crababel.locale("en").welcome_user(name: "Alice") # => "Hello Alice"
Crababel.locale("en").route(origin: "Berlin", destination: "Paris") # => "From Berlin to Paris"
Escape interpolation syntax with a backslash when it should remain literal text:
en:
literal: "Hello \\#{name}"
Crababel.locale("en").literal # => "Hello #{name}"
Development
Install dependencies and run the specs:
shards install
crystal spec
Contributing
- Fork it (https://github.com/your-github-user/crababel/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Stefan Bilharz - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.3.0- Tagged
- Sep 26, 2026
- Commit
8502a41ca8e3- Crystal
>= 1.18.2- Indexed
- yes
Dependents
Repository
github.com/sbsoftware/crababel
Metadata
- Created
- Aug 19, 2026
- Updated
- Oct 12, 2026
- Synced
- Oct 12, 2026
- Versions
- 4