-
-
Notifications
You must be signed in to change notification settings - Fork 483
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
feat: Dynamic route parameters translation #345
Conversation
Codecov Report
@@ Coverage Diff @@
## 6.x #345 +/- ##
===================================
Coverage 100% 100%
===================================
Files 2 2
Lines 6 6
===================================
Hits 6 6 Continue to review full report at Codecov.
|
e4033ca
to
04373ef
Compare
@rchl If you get the chance to have a look at this, please let me know what you think. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank's for for reaching out to me to get my opinion.
I'm gonna keep looking more and thinking about it but first thing that comes to my mind is that I don't like the fact that this feature is dependant on store. I have personally never used i18n store as I didn't see the point of it. All it seems to do for me is duplicating all translation strings
that are already available in bundles, making page slower to load. So I would prefer that this feature doesn't require one to enable store. From the top of my head, I don't have better solution but maybe we can think of something :).
Wouldn't it be simpler if switchLocalePath accepted an optional object with that information that is currently passed through store? |
Alternatively, I wonder if completely declarative approach is possible. That is, extract that information from pages at built time and maybe use |
Thanks for the feedback @rchl
I think that users typically don't want to call
Since we're dealing with dynamic paths here, we can't really get the required data at build time because it might result in huge payloads in router meta if we were to handle all possible parameters & translations for all dynamic routes. Additionally, since the data will most likely grow between each build, the router will frequently be out-of-sync with the database.
Agreed. I ended up going for this solution even though I'm not a fan of it because I can't seem to make anything else work properly. Ideally, I'd like nuxt-i18n to expose a custom method trough pages components Any thoughts? |
To clarify my thoughts here. I think that your suggestion would absolutely be valid and we probably should implement it anyway. But if I'm not mistaken, it's not compatible with using a "global" lang switcher in the layout, it would require users to render the lang switcher in every page, specifying translated parameters where needed, which could get a bit tedious in large applications. |
Good point about having language switcher in the layout. Then that wouldn't work if data would be returned from page's In that case I guess we should go for current solution. I wonder though, given that it will be a major version, should we disable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems OK to me. Feel free to either address my comments or not. :)
Thanks for the great suggestions @rchl, I'll address them ASAP. |
6781612
to
17f17d8
Compare
Adds support for translating dynamic route parameters via the Vuex store module BREAKING CHANGE: `preserveState` is now set automatically when registering the store module and cannot be set via the configuration anymore close #79
17f17d8
to
b8f638b
Compare
* feat: Dynamic route parameters translation Adds support for translating dynamic route parameters via the Vuex store module BREAKING CHANGE: `preserveState` is now set automatically when registering the store module and cannot be set via the configuration anymore close #79
* feat: Dynamic route parameters translation Adds support for translating dynamic route parameters via the Vuex store module BREAKING CHANGE: `preserveState` is now set automatically when registering the store module and cannot be set via the configuration anymore close #79
* feat: Dynamic route parameters translation Adds support for translating dynamic route parameters via the Vuex store module BREAKING CHANGE: `preserveState` is now set automatically when registering the store module and cannot be set via the configuration anymore close #79
What's new?
Adds support for translating dynamic route parameters via the Vuex store module
BREAKING CHANGE:
preserveState
is now set automatically when registering the store module andcannot be set via the configuration anymore
So why do we need this?
When using
switchLocalePath
to create a global lang switcher component, there's currently no way for the method to know how to translate dynamic parameters. This is an attempt to address this issue.How to test this?
This has been published as a prerelease on NPM, to test this version, install
v6.0.0-0
with Yarn:Or NPM:
Refer to the new documentation section to see how to use this in your app: Dynamic route parameters
close #79