You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently it is possible to customize the translation to be used based on the action. This is done, by asking the builder for its lookup_action, which get's the controller action's name and runs it through a simple mapping to map 'create' => 'new' and 'update' => 'edit' and configuring the locales:
In my case, Notification is a general purpose way of notifying users about different things and has different delivery mechanisms: in-app message, email, push notifications. So my labels, placeholders and hints might differ depending on the controller the form is being rendered. Often the show action of this controllers also includes a @notification to render a form in the footer.
en:
simple_form:
hints:
notification:
new:
title: This is the subject of the message sent to the user.
Solutions
I'm proposing two different ways to accomplish this. I would like to hear feedback on the desirability of the feature and the feasibility of the proposed solutions. I'm inclining for B, and might start a PR soon as a proof of concept.
A. Include Controller in the Lookup
en:
simple_form:
hints:
notification:
# Additions:'activities#show':
title: This is the content of the Push Notification received by the user.'photos#show':
title: This would be the subject of the email received by the user
When rendering activities#show ideally this looks the entire controller/action pair, before falling back to the action or to the defaults:
notification.activities#show.title
notification.show.title
notification.title
B. Pass an option to the form to "namespace" the lookup further:
en:
simple_form:
hints:
notification:
# Additions:email:
title: This is the content of the Push Notification received by the user.
Currently it is possible to customize the translation to be used based on the action. This is done, by asking the builder for its
lookup_action
, which get's the controller action's name and runs it through a simple mapping to map'create' => 'new'
and'update' => 'edit'
and configuring the locales:In my case,
Notification
is a general purpose way of notifying users about different things and has different delivery mechanisms: in-app message, email, push notifications. So my labels, placeholders and hints might differ depending on the controller the form is being rendered. Often the show action of this controllers also includes a@notification
to render a form in the footer.Solutions
I'm proposing two different ways to accomplish this. I would like to hear feedback on the desirability of the feature and the feasibility of the proposed solutions. I'm inclining for B, and might start a PR soon as a proof of concept.
A. Include Controller in the Lookup
When rendering activities#show ideally this looks the entire controller/action pair, before falling back to the action or to the defaults:
notification.activities#show.title
notification.show.title
notification.title
B. Pass an option to the form to "namespace" the lookup further:
Ideally this looks for the custom lookup first, before falling back to the action and the defaults:
notification.email.title
notification.show.title
notification.title
The text was updated successfully, but these errors were encountered: