Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure Ruby on Rails app to use Buddhist calendar?

In Buddhist Era calendar it's already 2555 year. What is the easiest way to make Date.current show 2555 instead of 2012?

UPDATE

I've found solution for this particular task. It can be easily implemented with just standard rails i18n.

cat config/locales/th.rb

{
  th: {
    date: {
      formats: {
        default: lambda { |date, _| "%d.%m.#{date.year + 543}" }
      }
    }
  }
}

and then just use I18n.l method:

ruby-1.9.3-p194 :032 > I18n.l(Date.current)
 => "30.10.2555"
like image 684
Alexander Balashov Avatar asked Nov 03 '22 12:11

Alexander Balashov


1 Answers

This might be what you're looking for.

https://github.com/ai/r18n

R18n.set('th')
R18n.l Time.now, :full #=> "1 พฤศจิกายน, 2554 12:00"
like image 60
Andrew Wei Avatar answered Nov 12 '22 14:11

Andrew Wei