Skip to content

Added a global store to save current language and started using Localstorage to persist selected language.#613

Merged
marcgc21 merged 6 commits intoruxailab:developfrom
sahitya-chandra:language-to-localstorage
Apr 1, 2025
Merged

Added a global store to save current language and started using Localstorage to persist selected language.#613
marcgc21 merged 6 commits intoruxailab:developfrom
sahitya-chandra:language-to-localstorage

Conversation

@sahitya-chandra
Copy link
Member

@sahitya-chandra sahitya-chandra commented Feb 27, 2025

Description

  1. Created a global store to save language globally. So that when the user navigates to a different route or page, the language cannot change back to the default language.
  2. Started using local-storage to store current language for persistence. This will also help store the current language after a refresh.
    Both the points will lead to better UX.
Screencast.from.2025-02-25.22-58-38.webm
Screencast.from.2025-02-25.22-57-31.webm

@sahitya-chandra sahitya-chandra changed the title Created a store to save current language globally and started using local-storage to store current language for persistence Added a global store to save current language and started using Localstorage to persist selected language. Mar 5, 2025
@sahitya-chandra
Copy link
Member Author

@marcgc21 Sir please review this also

@drp5
Copy link
Contributor

drp5 commented Mar 18, 2025

Hi @marcgc21 !! Could you add me as a reviewer in this PR?

@@ -0,0 +1,28 @@
const state = {
lang: localStorage.getItem('lang') || 'en',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider wrapping localStorage.getItem in a try/catch block to prevent runtime errors.

const mutations = {
SET_LANG(state, lang) {
state.lang = lang;
localStorage.setItem('lang', lang); // Persist language in localStorage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be useful to validate that lang is a supported language before committing.

@drp5
Copy link
Contributor

drp5 commented Mar 26, 2025

Hi @sahitya-chandra, you should resolve the conflicts in order to merge it.

@sahitya-chandra
Copy link
Member Author

sahitya-chandra commented Mar 26, 2025

@drp5 Sir I am currently little busy writing my proposal, and I also have mid exams in 2 days. So, I will fix them soon...

@sonarqubecloud
Copy link

@marcgc21 marcgc21 merged commit 361c518 into ruxailab:develop Apr 1, 2025
3 of 4 checks passed
@sahitya-chandra sahitya-chandra deleted the language-to-localstorage branch April 5, 2025 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants