Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does ruby have getlocale method?

Tags:

ruby

I need to detect language in Ruby without any rubygems installed. Both Python and Perl do have locale 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

like image 903
lzap Avatar asked Jan 23 '13 14:01

lzap


1 Answers

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

I18n.locale

Also, check your application.rb file if you want to set defaults like so:

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

If you don't have access to ANY gems, including Rails, take a look at how svenfuchs implemented it: https://github.com/svenfuchs/i18n

Quick question though: you do know you could vendor gems and use them without access to rubygems right?

like image 94
mathieugagne Avatar answered Oct 06 '22 18:10

mathieugagne