Skip to content

feat: store language code#2481

Closed
overskul wants to merge 1 commit into
Acode-Foundation:mainfrom
overskul:patch-3
Closed

feat: store language code#2481
overskul wants to merge 1 commit into
Acode-Foundation:mainfrom
overskul:patch-3

Conversation

@overskul

Copy link
Copy Markdown
Contributor

store language code in local storage

store language code in local storage
@greptile-apps

greptile-apps Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR stores the selected language code in browser storage. The main changes are:

  • Lowercase and resolve the requested language code.
  • Fall back to en-us for unsupported codes.
  • Save the resolved code to window.localStorage["language"] after loading strings.

Confidence Score: 4/5

The language persistence path can save stale or inconsistent state during settings changes.

  • Fast language changes can persist an older selection after the newer one.
  • Storage write failures can leave settings, strings, and stored language out of sync.
  • Unsupported browser language codes are normalized to the fallback before being stored.

src/lib/lang.js

Important Files Changed

Filename Overview
src/lib/lang.js Adds localStorage persistence to language setup, with async ordering and storage-error risks in the settings update flow.

Reviews (1): Last reviewed commit: "feat: store language code" | Re-trigger Greptile

Comment thread src/lib/lang.js
const lang = langMap[code] || langMap[code = "en-us"];
const strings = await lang.strings();
window.strings = strings.default;
window.localStorage["language"] = code;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Stale Language Wins Race

When settings.applyLangSetting() fires lang.set(value) without awaiting it, two quick language changes can resolve out of order. The older lang.strings() import can finish last and this line then persists the stale code, so the next startup can restore a language different from the user's latest selection.

Comment thread src/lib/lang.js
const lang = langMap[code] || langMap[code = "en-us"];
const strings = await lang.strings();
window.strings = strings.default;
window.localStorage["language"] = code;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Storage Failure Leaves Split State

When storage is unavailable or throws, this new write rejects after window.strings has already been updated. The settings-change path does not await lang.set(value), so the saved setting, in-memory strings, and persisted language value can diverge without the caller seeing the failure.

Comment thread src/lib/lang.js
Comment on lines +193 to +196
const lang = langMap[code] || langMap[code = "en-us"];
const strings = await lang.strings();
window.strings = strings.default;
window.localStorage["language"] = code;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Fallback Overwrites Requested Code

For an unsupported input such as a fresh-install navigator.language value of en or es, the fallback expression rewrites code to en-us before the new persistence step. That stores the fallback instead of the requested language code, so anything reading localStorage["language"] loses the original browser/user language value.

@overskul overskul closed this Jul 12, 2026
@github-project-automation github-project-automation Bot moved this from Backlog to Done in The Code Board - Acode Jul 12, 2026
@UnschooledGamer UnschooledGamer moved this from Done to 🫡 Done by Community in The Code Board - Acode Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🫡 Done by Community

Development

Successfully merging this pull request may close these issues.

2 participants