Skip to content

Instantly share code, notes, and snippets.

@henrik
Created February 4, 2010 13:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save henrik/294609 to your computer and use it in GitHub Desktop.
Save henrik/294609 to your computer and use it in GitHub Desktop.
Globalize1 view translation compatibility layer for Rails i18n.
# config/initializers/i18n.rb
# Globalize 1 compatibility. To be refactored away.
class GlobalizeTranslation < ActiveRecord::Base; end
class Globalize::ViewTranslation < GlobalizeTranslation; end
LANGUAGE_ID_EN = 1819
class String
def t
if I18n.locale == I18n.default_locale
self
else
record = GlobalizeTranslation.find_by_language_id_and_tr_key(LANGUAGE_ID_EN, self)
record && !record.text.blank? && record.text || self
end
end
def /(arg)
self.t % arg
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment