Last active
August 29, 2015 14:01
-
-
Save pixeltrix/99bf43eb612a667dc5c2 to your computer and use it in GitHub Desktop.
Response to http://www.naildrivin5.com/blog/2014/05/27/rails-does-not-define-your-application-architecture.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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