Skip to content

fix: resolve bare detected-language tags to the user's regional spelling dictionary#41

Open
hiimdec wants to merge 1 commit into
johnbean393:mainfrom
hiimdec:fix/regional-spelling-dictionary
Open

fix: resolve bare detected-language tags to the user's regional spelling dictionary#41
hiimdec wants to merge 1 commit into
johnbean393:mainfrom
hiimdec:fix/regional-spelling-dictionary

Conversation

@hiimdec

@hiimdec hiimdec commented Jul 12, 2026

Copy link
Copy Markdown

NLLanguageRecognizer emits base tags only ("en", never "en-GB"), and both spell-language resolvers exact-match that against NSSpellChecker.availableLanguages — landing on the generic "en" dictionary, which is US-flavoured. On a British-English system this makes the in-beam typo guard drop correctly-spelled branches (colour, realise), the dead-end guard suppress completions mid-word (completions("en", "colou") returns 0), and the correction lane liable to "fix" British spellings toward US.

This PR adds a shared resolver (SpellingLanguage.resolve): a bare base tag is first refined with the user's preferred regional variant of that language (Locale.preferredLanguages — the same OS-derived signal ADR-089 uses for prompt style) before falling back to exact match, base, and nil. US-preference systems are unchanged (en_US isn't an installed dictionary; resolution falls back to "en" as before); other languages with regional preferences (e.g. fr-CA) gain the same refinement. Verified against the live checker: enen_GB on an en-GB system, British words recognised, color/realize still flagged.

Corresponds to ADR-116 in my fork's decision log; happy to adjust numbering/format to your conventions.

🤖 Generated with Claude Code

…onary

NLLanguageRecognizer only emits base tags ("en"), which both spell-language
resolvers exact-matched to the generic "en" dictionary — US-flavoured, so on
a British-English Mac the typo guard killed branches closing colour/realise/
organise and the dead-end guard suppressed completions mid-word ("colou" has
zero completions under "en"). New shared SpellingLanguage.resolve refines a
bare base tag with the user's preferred regional variant (Locale.
preferredLanguages, per ADR-089's precedent) before falling back. ADR-116.

Verified by compiling the real source with a harness against the live
NSSpellChecker: en→en_GB on this system, British words recognised, US
behaviour unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant