I would put the translation functions in a separate function (i.e. translatePage()
) and call it the first time during init
and a second time when the click
event handler is fired.
Also, i18next comes with cookie storage (initialized with useCookie: true
); you can use this to store your current language with $.i18n.setLng
and retrieve it with $.i18n.lng()
functions. Then it's easy to redirect to each URI.
I hope this helps.