ArangoI18n
This gem lets you use the ArangoDB multi-modal database as an I18n backend in your Ruby projects.
Installation
Add this line to your application's Gemfile:
gem 'arango_i18n'
And then execute:
$ bundle
Or install it yourself as:
$ gem install arango_i18n
Usage
Using this gem with a Rails project might look something like this:
# config/initializers/i18n_backend.rb
database = Ashikawa::Core::Database.new do |config|
config.url = "http://localhost:8529"
config.database_name = 'my_app_i18n'
config.username = ""
config.password = ""
end
# database.collection("i18n") will return a collection object
# The collection will be created if it does not exist
I18n.backend = I18n::Backend::KeyValue.new(ArangoI18n::Store.new(database.collection("i18n")))
If there are existing translations lurking in config/locales/*.yml you probably will want to load them in with this:
I18n.backend.load_translations
Then end result of the code above is that the my_app_i18n database would have a collection called "i18n" which contains a bunch of documents that look something like this:
{ "key": "en.hello", "value": "\"Hello world\"" }
{ "key": "fr.hello", "value": "\"Bonjour le monde\"" }
Your translations then work as normal:
[3] pry(#<#<Class:0x007f06e47ef788>>)> t("hello")
=> "Hello world"
[4] pry(#<#<Class:0x007f06e47ef788>>)> I18n.locale = :fr
=> :fr
[5] pry(#<#<Class:0x007f06e47ef788>>)> t("hello")
=> "Bonjour le monde"
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
to create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Contributing
If you see something that can be improved, let me know. Open an issue, or send a pull request.
- Fork it ( https://github.com/sleepycat/arango_i18n/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