Skip to content

Instantly share code, notes, and snippets.

@pixeltrix
Last active August 29, 2015 14:01
Show Gist options
  • Save pixeltrix/99bf43eb612a667dc5c2 to your computer and use it in GitHub Desktop.
Save pixeltrix/99bf43eb612a667dc5c2 to your computer and use it in GitHub Desktop.
en:
short_names:
default:
male: "Mr %{surname}"
female: "Ms %{surname}"
full_names:
default:
male: "%{given_name} %{surname}"
female: "%{given_name} %{surname}"
not_specified: "%{given_name} %{surname}"
nationalities:
chinese:
male: "%{surname} %{given_name}"
female: "%{surname} %{given_name}"
not_specified: "%{surname} %{given_name}"
class Person < ActiveRecord::Base
def name
given_name? ? full_name : short_name
end
def short_name
I18n.t nationality, surname: surname,
scope: :"short_names.nationalities.#{gender}",
default: I18n.t(:"short_names.default.#{gender}")
end
def full_name
I18n.t nationality,
given_name: given_name, surname: surname,
scope: :"full_names.nationalities.#{gender}",
default: I18n.t(:"full_names.default.#{gender}")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment