Replies: 1 comment 1 reply
-
Isn't this solved by using phlex-translation as the docs mention? The only caveat is that if you have |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Whattup y'all. So, phlex-translate exists, but in a Rails app I'd like to take advantage of the built in translation inference and lazy lookup biz as much as possible. Rails translate is accessible through
helpers
, but if you hithelpers.translate(".some_scoped_key")
you getCannot use t(".some_scoped_key") shortcut because path is not available
. The unavailable path comes from the@virtual_path
instance variable on the view context. Anyways, I ended up here:This allows me to make components like:
Now when Thing goes to render it'll first look at "businesses.show.thing" before falling back to "components.thing", allowing me to have an overrideable default where-ever I use the component.
And lemme tell you it works out real nice. Now, other than that setting an instance variable on another object directly is gross, is anything wrong with this approach?
Beta Was this translation helpful? Give feedback.
All reactions