Functionality
The forceLocale
function allows the publisher to force AdConsent to be shown in GDPR in a specific language, regardless of the user language. Passing an invalid or unsupported language code will default to 'en'
, or the language set through the setDefaultLocale call.
Syntax
function adconsent.gdpr()
argument name | type | optional | value | description |
---|---|---|---|---|
command | string |
| ||
parameter | string |
| 2-letter country language code. Default value is | |
callback | function | ✔️ |
| The callback function that is called with the function call result. |
parameter
This is a string holding the 2-letter code for the country language the publisher wants AdConsent to use in GDPR. This language must be one of the supported languages in GDPR, otherwise forceLocale
will not be applied.
Valid language codes for GDPR
'cs'
(Czech)'de'
(German)'el'
(Greek)'en'
(English)'es'
(Spanish)'fr'
(French)'hr'
(Croatian)'hu'
(Hungarian)'it'
(Italian)'nl'
(Dutch)'pl'
(Polish)'pt'
(Portuguese)'sv'
(Swedish)
Description
When AdConsent shows the GDPR GUI it will show it by default in the users browser language. forceLocale
is used to override the browser language and always show the GUI in a specific language.
Using this function will allow the publisher to change the language shown to the users to a single language. This is especially useful if a site provides content only in one language, in that case the AdConsent GUI will also show only in this forced language.
An alternative way for managing different languages is to use setDefaultLocale to show users with non-supported languages, the publishers site main language in the AdConsent GUI.
Scope
The function must be called before AdConsent shows the GUI. Calls after AdConsent has shown the GUI will be ignored.
Example
Forcing language to German (de)
adconsent.gdpr('forceLocale', 'de');