Is it possible to change the value of the field based on the the browser's language? On my Drupal 8 website I have a content type "Video" which has an "Embed Code" field. Later the user is able to watch the video inside the platform. The value for this field usually looks like this: 

&lt;iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/some_link" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen&gt;&lt;/iframe&gt;


Is there a way to change the source link based on the language of the browser? So for example when the user browser's language is set to "FR", then I would like to append to the emded link the french captions, so that the link looks following ? 

https://www.youtube-nocookie.com/embed/some_link?cc_load_policy=1&amp;cc_lang_pref=fr
This is the plugin what also core using for browser language negotiation. You can have a closer look what the plugin exactly does: \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationBrowser

The code

$language_negotiation_method_manager = $this-&gt;container-&gt;get('plugin.manager.language_negotiation_method');
$plugin_id = LanguageNegotiationBrowser::METHOD_ID;
/** @var \Drupal\language\LanguageNegotiationMethodInterface $language_negotiation_method */
$language_negotiation_method = $language_negotiation_method_manager-&gt;createInstance($plugin_id);
$request = $this-&gt;container-&gt;get('request_stack')-&gt;getCurrentRequest();
$browser_langcode = $language_negotiation_method-&gt;getLangcode($request);


This will either give you back a valid language code or FALSE if the negotiation was unsuccessful. 

Regarding the dependencies


$container is only used as an example to show which services are being used.
Request is always present as an argument when you are in a controller.