0.0
No commit activity in last 3 years
No release in over 3 years
An I18n config class that looks at the LANGUAGE, LC_ALL, LC_MESSAGES, and LOCALE environment variables to determine I18n.locale
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.10
~> 5.0
~> 10.0

Runtime

~> 0.5
 Project Readme

I18n::Env::Config

Build Status

Set I18n.locale based on the environment variables that control the locale.

This is for Desktop applications only. For web application see http_accept_languge or http-accept.

Usage

require "i18n"
require "i18n/env/config"

I18n.config = I18n::Env::Config.new

Now I18n.locale will be derived from the user's environment.

Environment Variables

The following environment variables are searched, in order:

  1. LANGUAGE
  2. LC_ALL
  3. LC_MESSAGES
  4. LANG

(Just like gettext).

If an exact match is not found, the list is reevaluated using the locale's parent(s). E.g., if en_US is not found, we see if en is available.

Installation

Add this line to your application's Gemfile:

gem "i18n-env-config"

And then execute:

$ bundle

Or install it yourself as:

$ gem install i18n-env-config

License

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