Skip to content

Change locale code function to use Scratch.vm.getLocale() (as well as a few other things) - #9

Merged
ScratchFakemon merged 3 commits into
ScratchFakemon:Localefrom
pid-j:Locale
Sep 2, 2026
Merged

ScratchFakemon merged 3 commits into
ScratchFakemon:Localefrom
pid-j:Locale

Conversation

@pid-j

@pid-j pid-j commented Sep 2, 2026

Copy link
Copy Markdown

Based on my findings, Scratch.vm.getLocale() can be used instead of ReduxStore.getState().locales.locale. I wrote a simple custom extension to demonstrate:

In TurboWarp Desktop, Scratch.vm.getLocale() and ReduxStore.getState().locales.locale return the same thing while navigator.languages[0] returns the language of my system (set to Malay):

image

The packager environment caused Scratch.vm.getLocale() to return the same value as navigator.languages[0] (at least, I assume); this isn't an issue, since the old implementation returned navigator.languages[0] if ReduxStore was not available. Since this is in the packager, the ReduxStore locale code check fails and returns nothing:

image

As for the other changes, I used a guard clause to clean both _filterArray and getLanguageArray up by juust a tiny bit.

I could naively remove the fallback for navigator.languages[0] in getLanguageCode, but I won't; it's always good to have a fallback.

@ScratchFakemon

Copy link
Copy Markdown
Owner

!format

@ScratchFakemon

Copy link
Copy Markdown
Owner

wait dangocat doesnt work here i dont think

@ScratchFakemon

Copy link
Copy Markdown
Owner

i'll just merge it and fix it on my end

@ScratchFakemon
ScratchFakemon merged commit 39f3a50 into ScratchFakemon:Locale Sep 2, 2026
4 of 5 checks passed
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.

2 participants