Hello, I'm Paul. I am a devoted Linux user, Ruby programmer, Open Source software developer, photography hobbyist, and a world traveller. My wife Eugenia and I originate from a place in Russian Siberia. Today we live at the very South of Canada.
Since Gettext plugin does not work with Rails 2.2.2 any more, and I don’t like the syntax of bundled I18n, I’ve made a mix-in to extend functionality of String class with
module Ppds module CoreExtensions module String module TextHelper def t(*args) I18n.t self, default: self.to_s, value: args end end end end end class String include Ppds::CoreExtensions::String::TextHelper end
Now I can write
and get either a translation if one exists, or the original phrase, like Gettext behaves.
It also let you translate along with substitution:
first_name = "Paul" "My name is %s".t(first_name)