-
-
Notifications
You must be signed in to change notification settings - Fork 822
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
#419 - Added support for components localization #479
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/shoelace/shoelace/5TEPyXWS2AFgvzqnPBbwUHREbpgt |
[Edit] tl;dr: "Singleton object" is not an anti-pattern per se. But it is often an anti-pattern when there are inflexible and unnecessary tight couplings, in our case especially with components. I think we should avoid singletons whenever possible. @hanc2006 @claviska Hope you do not mind if again, I want to point out that singleton patterns are anti-patterns in most cases when dealing with i18n, due to the fact that many aspects of i18n may be contextual. Also trying to fix those singleton pattern issues, like I've proposed with this
To respond openly: No, it's not [Edit: at least not, if tightly coupled to components]. It's neither "similiar" nor "reasonable". The animation registries used by SL use an internal logic that shall never be changed, there are no (or at least no common) real-world scenarios where the internal behavioral strategy shall differ in certain contexts. Same for the singleton SL icon library registry, this is also completely noncontextual (fun fact, in the past there was this
If we are true to ourselves, if that was really "done quickly" we would not have used singleton patterns in the first place. I personally find the whole i18n stuff and how to abstract from it properly extremely difficult. For example the strategy of what shall be done if a translation cannot be found may differ completely between apps (one app may show the English version as fallback, a second may print out a warning and show Fixing those isses with patterns like the following (like already mentioned), will be a dead-end: // anti-pattern!
const PublicSingleton = {
setStrategy1(strategy: Strategy1) { ... },
setStrategy2(strategy: Strategy2) { ... },
doSomething(...) {...}
doSomethingElse(...) ...}
}
// anti-pattern!
const PublicSingleton2 = {
doSomething(strategy: Strategy1, ....) { ... },
doSomethingElse(strategy: Strategy2, ....) { ... }
} I really believe we should not spent too much time on things like that. I know it will cost several more hours more of brain power for all of us and also more annoying discussion, but in the end it will have been worth while (at least I hope so 😄). |
Closed in favor of this new PR #487. |
First draft for add component localization support using directive and locale. Discussion here: #419 (comment)