-
Notifications
You must be signed in to change notification settings - Fork 132
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
split language negotiation settings into detection
and storage
#1221
Comments
This should happen after the inlang core refactoring to be able to update the config automatically |
|
A user could not set any strategy if he wants to handle it manually. We then need to make sure that
|
We should make |
We should show a warining if the configured options do not make sense e.g. |
The API could look like this: type Config = {
detection: 'auto' | 'server' | 'client' | 'off'
storage: Strategy[]
}
type Strategy = { type: 'url' | 'localStorage' | 'cookie' /* ... */ }
If any combination does not make sense, we throw an error. The default config is: {
detection: 'auto',
storage: [{ type: 'url' }]
} |
Does it now still make sense to have Probably not and it would make things harder to explain. If the Conclusion: get rid of the |
Question: Does the SDK need so many options if the SDK is designed for best practices? For example, how to do language detection is surely defined as best practice by W3C. Same for how to persist the user's language. Should we even give options? Shouldn't we foster best practices? |
If we want to design a SDK that everyone uses, we need to provide some options. This API design does not mean we need to implement it. It just makes sure we can easily extend it in the future. The options we need for sure are currently defined here. The commented out options are nice to have for the future. |
After the refactoring, we should formulate design principles. I think we should design for the 80% use cases and foster best practices. We should rather make 80% of potential users really happy than 90% of users "okay happy" because too much config, still doesn't support edge cases, etc. The rest can build their own SDKs based on Anyhow, let's finish the refactoring first. |
Please tell me how we can support classical SPA and static SSR applications without those options? |
It seems clear that one Some ideas:
An example of a pluggable SDK-JS for a react user: modules: ["./inlang-sdk-plugin-react.js"],
settings: {
plugins: {
"inlang.sdk-plugin-react": {
options: {
// ... react specific options
},
},
},
}, For a sveltekit user: modules: ["./inlang-sdk-plugin-sveltekit.js"],
settings: {
plugins: {
"inlang.sdk-plugin-sveltekit": {
options: {
// ... sveltekit specific options
},
},
},
}, Pros
Cons
|
Another note, the Which raises another design principle question: Aren't metaframeworks just a feature? Why are we designing the SDK-JS around a feature instead of building the SDK-JS out as a platform that has a good metaframework feature? |
In my opinion the The arguments that now come up are not related to the original issue, but how to structure the settings. For adapter specific settings I was thinking about adding a prop to the top level of the sdk settings like this: "settings": {
"plugins": {
"inlang.sdk-js": {
"options": {
"sveltekit": {
// SvelteKit specific options
},
// all shared options
"resources": { }
},
},
},
}, This has the benefit of having a single config serving multiple applications without needing to specify everything multiple times. But since we now (finally) have decided to have dedicated packages for each adapter, we can think of splitting the settings also into dedicated plugins. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
How exactly language is determined/stored is very application specific. It makes a lot of sense to offer different algorithms and configuration to pick them. I'd also like to see ways to completely customize it and/or combine different ones. It's also different between ssr pages and spa. With ssr, the app should render |
some example code sveltejs/kit#6183 (comment) https://github.com/dominikg/kit-with-svelte-intl-precompile (outdated kit version but same stuff still applies today) |
Unfortunately, Ivan has passed away, and we are trying to find a solution. |
It is not so easy to know how to configure the
strategies
array in the sdk settings.There are multiple options someone can choose from and they slightly differ from each other. Some strategies are read-only because the application cannot update them and some of them can be altered.
read-only:
navigator
acceptLanguageHeader
others:
url
cookie
localStorage
sessionStorage
To make this more clear we should split them into
detection
andstorage
(or find some better words).The text was updated successfully, but these errors were encountered: