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

Support i18n key at translation of value in submit tag #26799

Merged
merged 1 commit into from Feb 27, 2018

Conversation

Projects
None yet
6 participants
@deraru
Contributor

deraru commented Oct 16, 2016

Summary

Currently submit tag value translation does not support i18n key style
locale key.
It confuses me a bit because many other components support i18n key
style locale key.
I added i18n key style locale key support to submit tag.

@rails-bot

This comment has been minimized.

Show comment
Hide comment
@rails-bot

rails-bot Oct 16, 2016

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @chancancode (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review.

Please see the contribution instructions for more information.

rails-bot commented Oct 16, 2016

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @chancancode (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review.

Please see the contribution instructions for more information.

@rafaelfranca

This comment has been minimized.

Show comment
Hide comment
@rafaelfranca

rafaelfranca Oct 16, 2016

Member

Could you explain better what is not supported now? For what I could see by the code i18n is supported

Member

rafaelfranca commented Oct 16, 2016

Could you explain better what is not supported now? For what I could see by the code i18n is supported

@deraru

This comment has been minimized.

Show comment
Hide comment
@deraru

deraru Oct 16, 2016

Contributor

I try to write code example.

class RichBlog::PoorPost << ActiveRecord::Base
end
en:
  activerecord:
    models:
      rich_blog/poor_post: blog post
    attributes:
      rich_blog/poor_post:
        title: post title
  helpers:
    submit:
      rich_blog_poor_post:
        create: Post my post

activerecord.models and activerecord.attributes (and more) keys allow rich_blog/poor_post.
But helpers.submit key does not allow rich_blog/poor_post.

Contributor

deraru commented Oct 16, 2016

I try to write code example.

class RichBlog::PoorPost << ActiveRecord::Base
end
en:
  activerecord:
    models:
      rich_blog/poor_post: blog post
    attributes:
      rich_blog/poor_post:
        title: post title
  helpers:
    submit:
      rich_blog_poor_post:
        create: Post my post

activerecord.models and activerecord.attributes (and more) keys allow rich_blog/poor_post.
But helpers.submit key does not allow rich_blog/poor_post.

@rafaelfranca

Thanks! It make sense to me. Could you add a test case and a CHANGELOG entry?

Show outdated Hide outdated actionview/lib/action_view/helpers/form_helper.rb Outdated
Show outdated Hide outdated actionview/lib/action_view/helpers/form_helper.rb Outdated
@deraru

This comment has been minimized.

Show comment
Hide comment
@deraru

deraru Oct 16, 2016

Contributor

Could you add a test case and a CHANGELOG entry?

Got it!

Contributor

deraru commented Oct 16, 2016

Could you add a test case and a CHANGELOG entry?

Got it!

@m5o

This comment has been minimized.

Show comment
Hide comment
@m5o

m5o Oct 25, 2016

i18n-debug is very useful to debug/visualize which translations are being looked up by Rails

Just in case you didn't know this handy helper 🤓

m5o commented Oct 25, 2016

i18n-debug is very useful to debug/visualize which translations are being looked up by Rails

Just in case you didn't know this handy helper 🤓

@deraru

This comment has been minimized.

Show comment
Hide comment
Contributor

deraru commented Oct 26, 2016

@deraru

This comment has been minimized.

Show comment
Hide comment
@deraru

deraru Dec 2, 2016

Contributor

@rafaelfranca Any update on this?

Contributor

deraru commented Dec 2, 2016

@rafaelfranca Any update on this?

@@ -2248,7 +2248,12 @@ def submit_default_value
end
defaults = []
defaults << :"helpers.submit.#{object_name}.#{key}"
# Object is a model and it is not overwritten by as and scope option.
if object.respond_to?(:model_name) && object_name.to_s == model.downcase

This comment has been minimized.

@deraru

deraru Jan 1, 2017

Contributor

Consider :as and :scope option is the top priority for i18n key.

@deraru

deraru Jan 1, 2017

Contributor

Consider :as and :scope option is the top priority for i18n key.

@@ -917,7 +920,7 @@ def test_submit_without_object_and_locale_strings
end
end
def test_submit_with_object_and_nested_lookup
def test_submit_with_object_which_is_overwritten_by_scope_option

This comment has been minimized.

@deraru

deraru Jan 1, 2017

Contributor

Not modified existing tests.

@deraru

deraru Jan 1, 2017

Contributor

Not modified existing tests.

@@ -931,6 +934,21 @@ def test_submit_with_object_and_nested_lookup
end
end
def test_submit_with_object_which_is_namespaced

This comment has been minimized.

@deraru

deraru Jan 1, 2017

Contributor

Add new test about code that I implemented.

@deraru

deraru Jan 1, 2017

Contributor

Add new test about code that I implemented.

@deraru

This comment has been minimized.

Show comment
Hide comment
@deraru

deraru Jan 1, 2017

Contributor

@rafaelfranca Could you review again?

Contributor

deraru commented Jan 1, 2017

@rafaelfranca Could you review again?

@deraru

This comment has been minimized.

Show comment
Hide comment
@deraru

deraru Feb 22, 2017

Contributor

@rafaelfranca Hello. Any updates on this?

Contributor

deraru commented Feb 22, 2017

@rafaelfranca Hello. Any updates on this?

@deraru

This comment has been minimized.

Show comment
Hide comment
@deraru

deraru Feb 27, 2018

Contributor

@rafaelfranca Hello, what should I do for this?

Contributor

deraru commented Feb 27, 2018

@rafaelfranca Hello, what should I do for this?

@rafaelfranca

This comment has been minimized.

Show comment
Hide comment
@rafaelfranca

rafaelfranca Feb 27, 2018

Member

Sorry, I dropped the ball here. Can you squash your commits and rebase this branch? The code looks good.

Member

rafaelfranca commented Feb 27, 2018

Sorry, I dropped the ball here. Can you squash your commits and rebase this branch? The code looks good.

@deraru

This comment has been minimized.

Show comment
Hide comment
@deraru

deraru Feb 27, 2018

Contributor

Thank you 😄 Got it!

Contributor

deraru commented Feb 27, 2018

Thank you 😄 Got it!

Change translation key of submit_tag from module_name_class_name to m…
…odule_name/class_name

Currently submit_tag value translation does not support i18n key style
locale key.
It confuses me a bit because many other components support i18n key
style locale key.
I added i18n key style locale key support to submit tag.

@rafaelfranca rafaelfranca merged commit f86b221 into rails:master Feb 27, 2018

2 checks passed

codeclimate All good!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@deraru

This comment has been minimized.

Show comment
Hide comment
@deraru

deraru Feb 27, 2018

Contributor

Wow! I'm so happy because this is a my first time Rails contribution!
Thank you @rafaelfranca !

Contributor

deraru commented Feb 27, 2018

Wow! I'm so happy because this is a my first time Rails contribution!
Thank you @rafaelfranca !

@deraru deraru deleted the deraru:support-i18n-key-in-submit-tag branch Feb 27, 2018

@rafaelfranca

This comment has been minimized.

Show comment
Hide comment
@rafaelfranca

rafaelfranca Feb 27, 2018

Member

Thank YOU! And welcome to the list of contributors http://contributors.rubyonrails.org/contributors/rui-onodera/commits

Member

rafaelfranca commented Feb 27, 2018

Thank YOU! And welcome to the list of contributors http://contributors.rubyonrails.org/contributors/rui-onodera/commits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment