Translate months in GUI

From Kolmisoft Wiki
Revision as of 09:12, 11 February 2010 by Mindaugas (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Lets say we want to have all months in GUI in Polish.

Then in /home/mor/config/environment.rb (make backup of this file before editing it!) at the very end add:

class Date
 Date::MONTHNAMES =  [nil] + %w(Styczeń Luty Marzec Kwiecień Maj Czerwiec Lipiec Sierpień Wrzesień Październik Listopad Grudzień)
 Date::DAYNAMES = %w(Domingo Lunes Martes Miércoles Jueves Viernes Sábado)
 Date::ABBR_MONTHNAMES = [nil] + %w(Ene Feb Mar Abr May Jun Jul Ago Sep Oct Nov Dic)
 Date::ABBR_DAYNAMES = %w(Dom Lun Mar Mié Jue Vie Sab)
end
class Time
 alias :strftime_nolocale :strftime
 def strftime(format)
   format = format.dup
   format.gsub!(/%a/, Date::ABBR_DAYNAMES[self.wday])
   format.gsub!(/%A/, Date::DAYNAMES[self.wday])
   format.gsub!(/%b/, Date::ABBR_MONTHNAMES[self.mon])
   format.gsub!(/%B/, Date::MONTHNAMES[self.mon])
   self.strftime_nolocale(format)
 end
end

Restart Apache after that.