In this article, I will try to explain my approach to develop a multi-language website with React Context API. If you are used to reading code bett...
For further actions, you may consider blocking this person and/or reporting abuse
thank you bro :)
Initial context doesn't change when calling userLanguageChange function.
export const LanguageBisContext = createContext({
userLanguage: "en",
dictionary: dictionaryList.en,
});
I am not sure to understand your point but it is working as expected and here is the demo nice-cliff-047044a03.azurestaticap...
Thanks, that was super helpful!
Is it somehow possible to put flag icons instead of country name? I've tried with tag but I'm getting [object Object] instead of images
Actually, your issue is about HTML most probably. I suppose you are trying to add img element in option tag of LanguageSelector.js You are most probably getting "Only strings and numbers are supported as option children" error in the console. So, if you want to use flags, you need to change the HTML structure of the LanguageSelector component.
Looks good! Will this work with SSR, specifically NextJS?
Thanks.
Honestly, I didn't try in any SSR project but, I don't see any reason not to work.
Really helpful post, tesekkur ederim! :)
That looks good! But how would it be when i want to set the language for the Alert (which is not a component) ???
Thank you very much, but there is a problem when using the tag on "placeholder"
It shows the following text: [object Object] Do you have a solution for this?
Thank you for the beneficial question. You can use the language context directly. I added an example about it via this commit: github.com/hcoz/react-context-mult...
Also, I will update the article by adding this example.