Language switcher, consulting browser's localStorage
The rewrite of LocalStorage is normal practice because of a rewrite time ~equal check time. 

You can change the code.

localStorage.setItem('lang', language);


By the way JSON.parse and  JSON.stringify is unnecessary actions in your code because language is already string.



I only considered the code associated with your the question.