Skip to content

Commit ec48d66

Browse files
authored
Merge pull request #24 from s-group-dev/language
Add features for specifying the CMP language
2 parents 0d50caf + 65cf3aa commit ec48d66

7 files changed

Lines changed: 3052 additions & 3366 deletions

File tree

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,16 @@ The script tag that loads the Usercentrics Browser UI and API.
8888
```tsx
8989
interface UsercentricsScriptProps
9090
extends React.DetailedHTMLProps<React.ScriptHTMLAttributes<HTMLScriptElement>, HTMLScriptElement> {
91+
/**
92+
* The language code the Usercentrics UI should load by default. If not set, it will be automatically selected.
93+
*
94+
* @example "fi"
95+
* @see https://usercentrics.atlassian.net/wiki/spaces/SKB/pages/1183678648
96+
*/
97+
language?: string
98+
9199
settingsId: string
100+
92101
/**
93102
* The specific version of Usercentrics UI to load instead of "latest", as a string value
94103
*
@@ -97,11 +106,13 @@ interface UsercentricsScriptProps
97106
* @see https://releases.usercentrics.com/en?category=browser+ui&role=cmpv1%3Bcmpv2%3B
98107
*/
99108
uiVersion?: string
109+
100110
/**
101111
* Whether to run Usercentrics in "production" or "preview" mode
102112
* @default "production"
103113
*/
104114
version?: 'production' | 'preview'
115+
105116
src?: never
106117
}
107118

@@ -113,6 +124,9 @@ interface UsercentricsScriptProps
113124

114125
/* Fixed UI version instead of latest */
115126
;() => <UsercentricsScript settingsId="1234" uiVersion="3.24.0" />
127+
128+
/* Fixed language code */
129+
;() => <UsercentricsScript settingsId="1234" language="fi" />
116130
```
117131

118132
#### `UsercentricsProvider`
@@ -454,3 +468,14 @@ A method to get array of all services from local storage
454468
const services = getServicesFromLocalStorage()
455469
const myService = services.find((service) => service.id === 'my-service-id')
456470
```
471+
472+
#### `updateLanguage`
473+
474+
Programmatic way to set language for the CMP.
475+
The param `countryCode` is a two character country code, e.g. "en" = set language to English
476+
477+
See also https://docs.usercentrics.com/#/cmp-v2-ui-api?id=updatelanguage
478+
479+
```tsx
480+
updateLanguage('fi')
481+
```

jest-setup.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
// eslint-disable-next-line import/extensions
2-
import '@testing-library/jest-dom/extend-expect'
1+
import '@testing-library/jest-dom'

0 commit comments

Comments
 (0)