Displaying Notices Based on Browser Language Preferences

You can display privacy notice content in the user's preferred language by passing it as a third parameter. This ensures the notice aligns with the language configured in the user's browser settings. To do this, you must modify the SDK script to integrate the privacy notice, allowing it to detect the browser language and automatically select the corresponding option in the dropdown. Use this method to fetch notice content in the preferred language:

OneTrust.NoticeApi.LoadNotices([noticeurl], trackNoticeLoad, languageCode)

  • The noticeurl represents the notice json url available as part of the integration SDK.

  • trackNoticeLoad is a boolean to decide if the notice loaded by the users should be tracked in the Locations tab on the Privacy Notice Details screen.

  • The languageCode is the preferred language code used to fetch notice content. This parameter can be utilized to pass on the language code by getting the preferred language using navigator.language.

Note:

If the preferred language is not setup in the Privacy Notice Management product, the SDK script will take care of loading the notice in the default language.

To integrate privacy notices to detect browser language

  1. On the Privacy Notice Management menu, select Privacy Notices. The Privacy Notices screen appears.
    Note:

    If you own the Policy Management module, the menu will be named Policy.

  2. Click the link in the Name column for the privacy notice you want to integrate. The Privacy Notice Details screen appears.

  3. Navigate to the Integration tab.

  4. Copy the SDK code and paste it into the component (HTML) where the privacy notice content should be displayed.
  5. Add OneTrust.NoticeApi.LoadNotices([noticeurl], trackNoticeLoad, languageCode) to the script. Here's an example of what this will look like in the component typescript.
    JAVASCRIPT
    <!-- OneTrust Privacy Notice start -->
      <!-- Language Drop-down element that will control in which language the Privacy Notice is displayed -->
      <div class="ot-privacy-notice-language-dropdown-container"></div>
      <!-- Container in which the Privacy Notice will be rendered -->
      <div id="notice-guid" class="otnotice"></div>
      <script src="https://{{domain}}/privacy-notice-scripts/otnotice-1.0.min.js" type="text/javascript" charset="UTF-8" id="otprivacy-notice-script">
          settings="eyJjYWxsYmFja1VybCI6Imh0dHBzOi8vbGtnYi1wb3J0YWwuMXRydXN0LmFwcC9yZXF1ZXN0L3YxL3ByaXZhY3lOb3RpY2VzL3N0YXRzL3ZpZXdzIiwiY29udGVudEFwaVVybCI6Imh0dHBzOi8vbGtnYi1wb3J0YWwuMXRydXN0LmFwcC9yZXF1ZXN0L3YxL2VudGVycHJpc2Vwb2xpY3kvZGlnaXRhbHBvbGljeS9jb250ZW50IiwibWV0YWRhdGFBcGlVcmwiOiJodHRwczovL2xrZ2ItcG9ydGFsLjF0cnVzdC5hcHAvcmVxdWVzdC92MS9lbnRlcnByaXNlcG9saWN5L2RpZ2l0YWxwb2xpY3kvbWV0YS1kYXRhIn0="
        </script>
      <script type="text/javascript" charset="UTF-8">
      // get the preferred language using navigator api
    		let preferredLanguage = navigator.language || navigator.userLanguage || "";
    		preferredLanguage = preferredLanguage.toLowerCase();
          // To ensure external settings are loaded, use the Initialized promise:
          OneTrust.NoticeApi.Initialized.then(function() {
            OneTrust.NoticeApi.LoadNotices(["notice-json-url"], true, preferredLanguage);
          });
        </script>
      <!-- OneTrust Privacy Notice end -->