Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
idontknowjs opened this issue Mar 11, 2021 · 9 comments
Open

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

idontknowjs opened this issue Mar 11, 2021 · 9 comments

Comments

@idontknowjs
Copy link

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
Copy link
Author

Hey @kelson42 , can I work on it :)

@kelson42
Copy link
Collaborator

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

@idontknowjs
Copy link
Author

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
Copy link
Author

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
Copy link
Member

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?

@kelson42 kelson42 added bug and removed question labels Mar 11, 2021
@stale
Copy link

stale bot commented Jun 2, 2021

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.

@stale stale bot added the stale label Jun 2, 2021
@idontknowjs
Copy link
Author

Do not mark it as stale

@stale stale bot removed the stale label Jun 2, 2021
@martin8032
Copy link
Collaborator

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
Copy link

stale bot commented Aug 21, 2021

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.

@stale stale bot added the stale label Aug 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants