Does ruby ​​getlocale method?

I need to define a language in Ruby without any rubigems. Both Python and Perl have local utilities as part of the core API. I want something like

# LC_ALL=cs_CZ ruby test.rb Your language is: cs_CZ Your currency is: CZK 

thanks

+7
source share
3 answers

Internationalization of Rails http://guides.rubyonrails.org/i18n.html

 I18n.locale 

Also check the application.rb file if you want to set the default values ​​as follows:

 I18n.default_locale = [:en] I18n.available_locales = [:en, :fr] 

If you don’t have access to ANY jewelry, including Rails, see how svenfuchs implemented it: https://github.com/svenfuchs/i18n p>

Quick question: do you know that you can sell gems and use them without access to rubigems?

+5
source

Does ENV["LANG"] for you?

0
source

Since this question is about Ruby, not Ruby on Rails, my need also, here is something outside of Rails:

Installing rubygem 'locale' (documented here ):

 $ gem install locale 

Using it:

 require 'rubygems' require 'locale' Locale.current = 'whateverlocaleyouwant' 

There is no such functionality in the Ruby core.

0
source

All Articles