Search code examples
rubylocalizationsinatrastrftime

How can I localize day name with strftime in ruby Sinatra


What is the best way to localise strftime in ruby (sinatra app) to have day name in French for example ?

I have :

"2012-06-04".strftime("%a") # => "Mon"

I want :

"2012-06-04".strftime("%a") # => "Lun"

Thank you!


Solution

  • Use R18n internationalization gem. In your case sinatra-r18n gem. It supports several locales.

    Taken from the sinatra example page:

    set :default_locale, 'fr'
    

    This will make the default locale to french.