Skip to content
Internationalization shard 🌍
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
locales
spec
src
.editorconfig
.gitignore
.travis.yml
LICENSE
README.md
shard.yml

README.md

I18n

Built with Crystal Build status API Docs Releases Awesome vladfaust.com Patrons count Gitter chat

Internationalization module for Crystal.

Supporters

Thanks to all my patrons, I can continue working on beautiful Open Source Software! πŸ™

Lauri Jutila, Alexander Maslov, Dainel Vera

You can become a patron too in exchange of prioritized support and other perks

Become Patron

Installation

Add this to your application's shard.yml:

dependencies:
  i18n:
    github: vladfaust/i18n.cr
    version: ~> 0.1.1

This shard follows Semantic Versioning 2.0.0, so see releases and change the version accordingly.

Usage

# es.yml
es:
  apples:
    one: 1 manzana
    other: "%{count} manzanas"
require "i18n"
require "i18n/backends/yaml"

I18n.backend = I18n::Backends::YAML.new.tap do |backend|
  backend.load_paths << Dir.current + "/locales"
  backend.load
end

I18n.default_locale # => "en"
I18n.locale = "es"

I18n.t("apples", count: 3) # => "3 manzanas"

You can implement your own I18n::Backend, as well as your own quantity keys rules ("one", "many" etc.). Read more in docs.

Development

Tests included! Run crystal spec while developing.

There is currently no code for localization currencies, date and time etc. If you need it, please open an issue and/or a pull request.

Contributing

  1. Fork it ( https://github.com/vladfaust/i18n.cr/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.