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
Adds support to localized components files #977
base: main
Are you sure you want to change the base?
Conversation
Benchmark: localized components:
main branch:
|
I'm doing some tests in a dummy app, with the following configuration: I18n.available_locales = [:en, :es, :fr]
I18n.default_locale = :en I'm adding a
Now If I'm removing this partial and restart the server : app/components/foo_component.en.html.erb
app/components/foo_component.fr.html.erb
- app/components/foo_component.html.erb
I guess it should work without a "default" partial, what do you think? EDIT: here is the standard behavior with localized views in Rails:
|
Thanks for reviewing it @Spone I think every case is expected as I used the There's a (test) for this.
This happened because there's no
Also expected, as the file
Without locale, but with |
In this case, Rails localized views fall back to the default locale (so
Yes but in this case Rails localized views fall back to the default locale as well.
Yes. Actually you can also remove it from the config since To sum up, I think the fall back behavior should be the same as Rails standard behavior with localized views, as described in the EDIT of my previous comment. What do you think? |
Thanks @Spone and @jonspalmer for the comments. I'll have a look into it carefully. |
@lfalcao is there any news on this PR? |
Related: #894
I just combined the "localized" information from component files (my_component.es.html.erb) into variant attribute to avoid adding new parameters or functions and worked well😄
It's not done yet, needs some work, more tests, benchmarks... but I wanted to see some opinions about this approach, if there's something else I'm not seeing.