No release in over a year
Adds support for fetching translation from a remote resource
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0

Runtime

~> 1.12
 Project Readme

I18n::RemoteBackend

I18n backend for loading remote locales via HTTP.

Installation

Put the following in your Gemfile:

gem 'i18n-remote_backend'

After updating your bundle, run the installer

$ rails g i18n:remote_backend:install

It generates a new file in config/initializers named i18n_remote_backend.rb with the following content.

require 'i18n/backend/remote_backend'

I18n.backend = I18n::Backend::Chain.new(I18n::Backend::RemoteBackend.new, I18n::Backend::Simple.new)

I18n::Backend::RemoteBackend.configure do |config|
  # config.http_url = ''
end

Set the http_url accordingly. e.g https://example-url/locales The corresponding generated requests will look like: https://example-url/locales/en or https://example-url/locales/fr etc. And it should respond back with the yaml file content.

If a remote translation is unavailable, it will fall back to a local translation.

Usage

You can then use I18n.t('text').

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/mudasirraza/i18n-remote_backend.

License

The gem is available as open source under the terms of the MIT License.