kiwix / web

Bugs, enhancements, ideas for our Web presence
https://kiwix.org
7 stars 6 forks source link

Default language preference of the page is not getting stored #134

Open idontknowjs opened 3 years ago

idontknowjs commented 3 years ago

Describe the bug The language changed on the website always open in en, irrespective the user might have already translated the website to a specific language. The language preference of the user is never stored. Once the tab is closed and when user visits website , the website loads in default en only

To Reproduce Steps to reproduce the behavior:

  1. Go to 'https://www.kiwix.org/fr/'
  2. Close the tab
  3. Visit 'https://www.kiwix.org/'

Expected behavior It should open in the translated language ie fr, https://www.kiwix.org/fr/

Additional context This could be achieved by storing the user language preference in local storage, and rendering the website depending upon the language value stored in local storage.

I would like to work upon this

idontknowjs commented 3 years ago

Hey @kelson42 , can I work on it :)

kelson42 commented 3 years ago

@covalentbond Explain first here how you want to fix it, and get an approval. Then you should provide the solution.

idontknowjs commented 3 years ago

We can write a function to detect the pathname of the webpage with window.location.pathname, depending upon the string variable. The value can be stored like window.localStorage.setItem('lang', 'fr').

Again whenever a user visits the page, it will check in window.localStorage if there is some preferred value present or not. If present then we can redirect the user to window.location.pathname + /{that_lang}, else it will render the page in en by default

idontknowjs commented 3 years ago

Other than that, a new feature can also be added to automatically detect the user's preferred language of the device - the website is being viewed on. You can console this value window.navigator.language, it will show the default language preference of the your device. And we automatically render it to fr or de.

But, I'm not aware where is the repository for kiwix.org :)

Popolechien commented 3 years ago

I confirm the issue (both on Chrome and Firefox) but considering the website is on Wordpress I'm slightly surprised we'd need a direct fix. @martin8032 thoughts?

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.

idontknowjs commented 3 years ago

Do not mark it as stale

martin8032 commented 3 years ago

This is something WPML (the multilingual plugin on our WordPress website) should handle, but as far as I can see it's not implemented yet:

https://wpml.org/forums/topic/remember-language-choice-3/

I agree that remembering the last language choice would be a nice feature. On the other hand, since so little of our website is currently translated I'd rather recommend to have an exclusively English website anyway.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.