Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect attribute translations in #check_box #126

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Respect attribute translations in #check_box #126

wants to merge 1 commit into from

Conversation

atipugin
Copy link

@coveralls
Copy link

Coverage Status

Coverage decreased (-29.74%) to 70.26% when pulling 66303f1 on atipugin:master into 98e0743 on Fullscreen:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 2dfd42a on atipugin:master into 98e0743 on Fullscreen:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 14969fe on atipugin:master into 98e0743 on Fullscreen:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 7ed8532 on atipugin:master into 98e0743 on Fullscreen:master.

klass = object.class
return method.to_s.humanize unless klass.respond_to?(:human_attribute_name)

klass.human_attribute_name(method)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work @atipugin ! I'll look into this human_attribute_name method a little (because I don't know it) before accepting.

Meanwhile, do you mind changing the syntax of this method? I don't like return … if … statements.
You could just write the following instead:

def default_label_for(method)
  if object.class.respond_to? :human_attribute_name
    object.class.human_attribute_name method
  else
    method.to_s.humanize
  end
end

Apart from that, I want to make check whether:

  • "default" is a good name for this method default_label_for. What is your rationale behind this name?
  • the code will work if human_attribute_name is defined, but then no translation exists for the method

Thanks again, everything else looks good!!!

@claudiofullscreen
Copy link
Contributor

Could you also squish all your commits together? Thanks! 🎀

@atipugin
Copy link
Author

Changed code to if/else statement. Answering your questions:

  1. "#default" is too ambiguous for this. Module itself handles whole checkbox, not only a label's text.
  2. Code will work. #human_attribute_names uses same #humanize as fallback for absent translations.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.05%) to 99.95% when pulling b758a6a on atipugin:master into 98e0743 on Fullscreen:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.05%) to 99.95% when pulling f10011d on atipugin:master into 98e0743 on Fullscreen:master.

@koenpunt
Copy link

Ping! 🌟

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants