Repository: electron
Issue: [Feature Request]: Support Windows spell check for non-Hunspell languages
Labels: enhancement :sparkles:,component/spellcheck

### Preflight Checklist

- [X] I have read the [Contributing Guidelines](https://github.com/electron/electron/blob/main/CONTRIBUTING.md) for this project.
- [X] I agree to follow the [Code of Conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) that this project adheres to.
- [X] I have searched the [issue tracker](https://www.github.com/electron/electron/issues) for a feature request that matches the one I want to file, without success.

### Problem Description

The [session.setSpellCheckerLanguages API](https://www.electronjs.org/docs/latest/api/session#sessetspellcheckerlanguageslanguages) currently only supports the hard-coded list of languages supported by Hunspell in `kSupportedSpellCheckerLanguages` in [components/spellcheck/common/spellcheck_common.cc](https://chromium.googlesource.com/chromium/src/+/8ba1bad80dc22235693a0dd41fe55c0fd2dbdabd/components/spellcheck/common/spellcheck_common.cc#30). This means that Electron doesn't provide spellcheck support for languages without Hunspell support (like Finnish), even though these languages are supported by the Windows API Electron already uses for Hunspell-compatible languages.

Chromium supports these, however, with support added in https://chromium-review.googlesource.com/c/chromium/src/+/2155167.

### Proposed Solution

In the implementation for `session.setSpellCheckerLanguages` ([Session::SetSpellCheckerLanguages](https://github.com/electron/electron/blob/6bfef67aaeae9613e85b3d5d3745da763b3ef7c4/shell/browser/api/electron_api_session.cc#L1082)), if I remove the `spellcheck::GetCorrespondingSpellCheckLanguage` call and just pass the language code through to the `spellcheck::prefs::kSpellCheckDictionaries` pref as-is, I’m able to use it in a test app by calling `session.setSpellCheckerLanguages(['fi'])` (for Finnish) and see Finnish spellchecking work in Electron (the API would otherwise throw the "Invalid language code" error).

Rather than remove the `spellcheck::GetCorrespondingSpellCheckLanguage` check, I suppose we'd need to supplement it with a check that the language passes [spellcheck_platform::PlatformSupportsLanguage](https://chromium.googlesource.com/chromium/src/+/12be03159fe22cd4ef291e9561762531c2589539/components/spellcheck/browser/spellcheck_platform.h#83) or is in the result of [spellcheck_platform::RetrieveSpellcheckLanguages](https://chromium.googlesource.com/chromium/src/+/12be03159fe22cd4ef291e9561762531c2589539/components/spellcheck/browser/spellcheck_platform.h#52), though that would require the API change to async.

I think fixing this would also require either changing [session.availableSpellCheckerLanguages](https://www.electronjs.org/docs/latest/api/session#sesavailablespellcheckerlanguages-readonly) to also return the supported languages for which the Windows language pack is installed (via [spellcheck_platform::RetrieveSpellcheckLanguages](https://chromium.googlesource.com/chromium/src/+/12be03159fe22cd4ef291e9561762531c2589539/components/spellcheck/browser/windows_spell_checker.cc#379)), or adding a new API for that (since it seems it would need to be retrieved async).

Maybe the list of available languages can be retrieved when a session is created?

### Alternatives Considered

n/a

### Additional Information

_No response_