-
Notifications
You must be signed in to change notification settings - Fork 57
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
multiple pages in an app using same translations #32
Comments
I really think wanting all instances of app-localize-behavior to use the same language is the common case. If I were to supply a pull request for this, would there be any interest in merging it? |
I wasn't saying it wasn't a real use case, I was mostly saying this is a thing you can do in your elements, not in the behaviour. To keep the behaviour as general as possible, for each of your element implementations you can set the value of the language to be Does that make sense? We try to avoid having globals on the I can put together a JSBin if this still doesn't make sense |
It does make sense, but I still have a concern. Suppose my app has 20 uses of this behavior and I want to have a single drop-down on a settings page that can change the language. How will I communicate that change to all the custom elements that use this behavior? I could invent my own mechanism to handle that. However, if this is something that many apps will want then maybe it is better for that functionality to be directly supported by the behavior. |
The Mediator pattern is not enough in this scenario. Some sort of global state is needed. There is also a global state aspect here: #39 |
@notwaldorf, I created a pull request that supports this with the minimum changes possible. It only requires changing app-localize-behavior to emit two event. |
I created a new pull request that correctly squashes my previous commits. Please reconsider this one: #44 |
Are there any plans on adding the AppLocalizeBehavior into the Starter Kit template? In the Starter Kit template there are multiple pages, and having multiple pages is most likely the common case, so this would be a great place to show us how we are supposed to use this behavior on multiple pages? Having separate resources is imho not very clean, besides small apps where they are inlined. |
If I read this correctly, this seems to be asking for functionality from #46 ("Sub-components should have language inherited"). If that's the case, then component authors with this problem might be interested in the alternative to use an ancestor's |
Description
If I understand correctly, when an app has multiple pages that use app-localize-behavior, each one needs to specify the language and call this.loadResources to load a translation file. I want to specify the language once for every use of app-localize-behavior in my app and call this.loadResources once.
Expected outcome
I can specify the language and the path to the translation file once and all uses of app-localize-behavior take advantage of those.
Actual outcome
I have to specify these things in every usage of app-localize-behavior.
Browsers Affected
all
The text was updated successfully, but these errors were encountered: