martinandert / react-translate-component

A component for React that utilizes the Counterpart module to provide multi-lingual/localized text content.
MIT License
322 stars 31 forks source link

Make Language Switcher work with "counterpart.translate" #41

Closed OfficialCRUGG closed 2 years ago

OfficialCRUGG commented 5 years ago

Hey there! I am currently working on my first real react project, and stumbled over a little problem. Once I implemented a language changer, it perfectly changes the translation of all Elements, but not of all elements that use counterpart.translate. I have some Elements in my Code, where I can't use the Element, so I had to use counterpart.translate. Here is an example:

<Link to="/blog" className="footer-link">{counterpart.translate("footer.community.blog")}</Link>

Does anybody haven an Idea on how I could refresh those as well?

martinandert commented 5 years ago

Maybe this helps (untested): https://gist.github.com/martinandert/c9ad5051833014e126f9e28c1911f09f