MicrosoftEdge / MicrosoftEdge/WebView2Feedback

ICoreWebView2EnvironmentOptions Language

Open
#1,875 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

Hello ,

how can change the ICoreWebView2EnvironmentOptions.Languge without recreate the webView

i try this but not work [DelphiCode]

var aEnvironment         : ICoreWebView2Environment;
    aEnvironmentOptions  : ICoreWebView2EnvironmentOptions;
    HR                   : HRESULT;
begin
  {
    aEnvironmentOptions not exist function to get this interface and change language ???

    Does the whole webView need to be recreated?

    ??? ???? ???
  }
  if Not WebViewCreated then exit;
  if Not LastWebViewIsValid then exit;
  // Get Environment from WebView
  aEnvironment := nil;
  HR           := FLastWebViewSupported.get_Environment(aEnvironment);

  if Assigned(aEnvironment) and ProcessHResultAM(HR)  then
 begin
    //Search interface ICoreWebView2EnvironmentOptions
    aEnvironment.QueryInterface(IID_ICoreWebView2EnvironmentOptions,aEnvironmentOptions)
  end
  else
    DoErrorLog('SetLanguage',Format('get_Environment error %d',[HR]));

  if not Assigned(aEnvironmentOptions) then
  begin
    DoErrorLog('SetLanguage','ICoreWebView2EnvironmentOptions not found');
    exit;
  end;
  // SetLanguage
  HR := aEnvironmentOptions.Set_Language(PChar(ifThen(String(FEdgeLanguage.LanguageISO3166)='',DEFAULT_ISO_3166_VALUE,String(FEdgeLanguage.LanguageISO3166))));

  if not ProcessHResultAM(HR) then
   DoErrorLog('SetLanguage',Format('Set_Language error %d',[HR]));

Thanks

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the ICoreWebView2EnvironmentOptions and get_Environment calls shown in the issue, then check the WebView2 API documentation for when Set_Language takes effect. Determine whether changing the language on an existing environment is supported or requires recreating the WebView. Done means documenting the supported behavior and any required lifecycle steps.

Written by the indexing model from the issue text.

Assessment

Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.