seven
seven

Reputation: 1674

How can i display different one trust cookie banner based on locale in NextJs app

I have a NextJs 12 app which have urls domain.com and domain.com/es we use OneTrus cookie banner in _document.ts like so

        <Head>
          <Script
            id="one-trust"
            strategy="beforeInteractive"
            src="https://cdn.cookielaw.org/scripttemplates/otSDKStub.js"
            data-domain-script="xxx"
          />
          <Script id="one-trust-optanonWrapper" type="text/javascript">
            function OptanonWrapper() {}
          </Script>
          <Favicon />
        </Head>

the new requirement is that on /es version the OntTrust cookie banner should be in spanish. We have information that it is setup in one trust manager, bu we are having hard times with setting it up on the frontend, does anyone know how can i enable spanish language in Cookie Banner on /es route? Many thanks.

Upvotes: 0

Views: 1431

Answers (1)

geoM
geoM

Reputation: 507

In the OneTrust settings, you can choose between

  1. determine the language from site visitor's browser settings
  2. determine the language from HTML page https://my.onetrust.com/articles/en_US/Knowledge/UUID-7478d3b4-18eb-3ac0-a6fd-fb7ebff9f8dc

If you go with 2, you need to make sure to set the lang attribute of the html element

Depending on your setup, you can use the i18n setup baked into Next.js to make sure that the lang attribute is set based on the locale(s) you want to support. You can also check that article on for more explanations: https://dev.to/dawsoncodes/how-to-set-html-lang-attribute-in-nextjs-39bg

Upvotes: 2

Related Questions