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

Set fallbacks per request? #405

Closed
molfar opened this issue Jul 3, 2020 · 7 comments
Closed

Set fallbacks per request? #405

molfar opened this issue Jul 3, 2020 · 7 comments

Comments

@molfar
Copy link

molfar commented Jul 3, 2020

I have a multi-country web app, and need to set different fallbacks schemas per each country. Is it possible to set dynamic fallbacks per request, just like Mobility.with_locale ?

@shioyama
Copy link
Owner

shioyama commented Jul 8, 2020

This is basically like #391 right?

@molfar
Copy link
Author

molfar commented Jul 8, 2020

Not exactly the same. My issue is about setting fallbacks dynamically and globally. Just like Mobility.with_locale works

@molfar
Copy link
Author

molfar commented Jul 8, 2020

I think it is related to I18n.fallbacks. Because there is not much sense without dynamic fallbacks there.

@timkrins
Copy link

Hi @molfar - I have done this in my own fork.
The usage is akin to

Mobility::Plugins::Fallbacks.with_fallbacks(fallbacks_override_array_or_false) do
   ...
end

I'll try create a PR over the weekend.

@sedubois
Copy link
Contributor

I am also interested in having fallbacks only in a specific block, e.g.:

Mobility.with_fallbacks(fallback_config) do
  ...
end

@doits
Copy link
Contributor

doits commented Oct 4, 2021

Just want to give a shout out to the plugin infrastructure of mobility. Once you grasp it, you can easily write your own fallback plugin to do exactly what you want. You can see my comment #328 (comment) for two examples I am using. Maybe you can use it as a starting point for your own fallback plugin?

@shioyama
Copy link
Owner

I made some comments about how plugins can be used in #328 (comment)

#538 is an attempt to make it a bit easier to create plugins without needing module builders (< Module) and/or included hooks.

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

No branches or pull requests

5 participants