Low commit activity in last 3 years
No release in over a year
Provides a backend to the i18n gem to allow a definition to contain embedded references to environment variables by introducing the special embedded notation ~{}. E.g. {title: ~{APP_NAME}} will evaluate t(:title) to the value of the $APP_NAME environment variable.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

I18n Env Var Lookup Build Status

Provides a backend to the i18n gem to allow a definition to contain embedded references to environment variables by introducing the special embedded marker ~{}.

All definitions are lazily evaluated on lookup, and once compiled they're written back to the translation store so that all interpolation happens once.

Example

# .env
APP_NAME=An International App

# example.yml
home:
  index:
    seo_title: Home | ~{APP_NAME}

<%= t '.seo_title' %> will correctly evaluate to Home | An International App.

Use double tildes to escape. e.g. ~~{APP_NAME}

Installation

Install the gem either by putting it in your Gemfile

gem 'i18n-env-var-lookup'

or by installing it using rubygems

gem install i18n-env-var-lookup

Add it to your existing backend by adding these lines to your config/initializers/i18n.rb (create one if one doesn't exist):

# config/initializers/i18n.rb
require 'i18n/backend/env_var_lookup'
I18n::Backend::Simple.send(:include, I18n::Backend::EnvVarLookup)

Of course you can replace the I18n::Backend::Simple with whatever backend you wish to use.

Credit

This gem is heavily inspired by the i18n-recursive-lookup gem