l10n support in ruby
Question: I am able to parse localized dates using [python locale
module](https://docs.python.org/2/library/locale.html) and posix localization
database:

    
    
    import locale, datetime
    
    locale.setlocale(locale.LC_TIME, 'tr_TR.UTF-8')
    print datetime.datetime.strptime("1 Haziran 2014", "%d %B %Y")
    

===

Edit

This example loads the locale and datetime modules, parses the localized date
to create an instance of python's datetime class. I'm looking specifically for
Ruby code that can parse localized dates using posix database.

===

Is there any equivalent of this in ruby? If there is a ruby library like
python's locale module or
[Boost.Locale](http://www.boost.org/doc/libs/1_55_0/libs/locale/doc/html/dates_times_timezones.html)
in C++, can you give example code? I tried the [gettext
gem](https://rubygems.org/gems/gettext) and [locale
gem](http://rubydoc.info/gems/locale/) (I set current locale and tried
[Time.strptime](http://www.ruby-
doc.org/stdlib-2.1.2/libdoc/date/rdoc/DateTime.html#method-c-strptime), which
failed).

I do not expect to do custom `gsub` or an i18n config file parsing. I am
asking for code that uses posix database to parse dates.


Answer: You will need 2 custom gems in your `Gemfile`

**Chronic:**

    
    
    $ git clone git://github.com/mojombo/chronic.git
    $ cd chronic && gem build chronic.gemspec
    $ gem install chronic-*.gem
    

**Chronic-l10n:**

    
    
    $ git clone git://github.com/luan/chronic-l10n.git
    $ cd chronic-l10n && gem build chronic-l10n.gemspec
    $ gem install chronic-l10n-*.gem
    

**Usage:**

    
    
    require 'chronic'
    require 'chronic-l10n'
    
    Time.now   #=> Sun Aug 27 23:18:25 PDT 2006
    
    Chronic.locale = :'pt-BR'
    
    Chronic.parse('amanhã')
      #=> Mon Aug 28 12:00:00 PDT 2006
    
    Chronic.parse('segunda', :context => :past)
      #=> Mon Aug 21 12:00:00 PDT 2006
    
    Chronic.parse('essa terça 5:00')
      #=> Tue Aug 29 17:00:00 PDT 2006
    
    Chronic.parse('essa terça 5:00', :ambiguous_time_range => :none)
      #=> Tue Aug 29 05:00:00 PDT 2006
    
    Chronic.parse('27 de maio', :now => Time.local(2000, 1, 1))
      #=> Sat May 27 12:00:00 PDT 2000
    
    Chronic.parse('27 de maio', :guess => false)
      #=> Sun May 27 00:00:00 PDT 2007..Mon May 28 00:00:00 PDT 2007
    
    Chronic.parse('6/4/2012', :endian_precedence => :little)
      #=> Fri Apr 06 00:00:00 PDT 2012
    

