|
10 | 10 | import { loadContent, loadSettings, checkEmailStatus } from './services'; |
11 | 11 | import { html, LitElement } from 'lit'; |
12 | 12 | import { property } from 'lit/decorators.js'; |
13 | | -import { |
14 | | - pwsValueMap, |
15 | | - resetToWorldWideContent, |
16 | | - supportedLanguages, |
17 | | -} from './utils'; |
| 13 | +import { pwsValueMap, resetToWorldWideContent } from './utils'; |
18 | 14 | import settings from '@carbon/ibmdotcom-utilities/es/utilities/settings/settings.js'; |
19 | 15 | import StableSelectorMixin from '../../globals/mixins/stable-selector'; |
20 | 16 | import styles from './notice-choice.scss'; |
@@ -161,6 +157,9 @@ class NoticeChoice extends StableSelectorMixin(LitElement) { |
161 | 157 | @property({ reflect: true }) |
162 | 158 | hiddenPhone = ''; |
163 | 159 |
|
| 160 | + @property({ type: Object, attribute: false }) |
| 161 | + supportedLanguages = {}; |
| 162 | + |
164 | 163 | connectedCallback() { |
165 | 164 | super.connectedCallback(); |
166 | 165 | this._initSettingsAndContent(this.language); |
@@ -203,15 +202,18 @@ class NoticeChoice extends StableSelectorMixin(LitElement) { |
203 | 202 | /[-_]/ |
204 | 203 | )[0]; |
205 | 204 | const supportedLang = |
206 | | - supportedLanguages(this.language) || |
207 | | - supportedLanguages(langPart) || |
| 205 | + (this.language && |
| 206 | + this.supportedLanguages[this.language?.toLowerCase()]) || |
| 207 | + (langPart && this.supportedLanguages[langPart?.toLowerCase()]) || |
208 | 208 | 'en'; |
209 | 209 |
|
210 | 210 | this.isLoading = true; |
211 | 211 | loadSettings( |
212 | 212 | this.environment, |
213 | 213 | (settings) => { |
214 | 214 | this.countrySettings = settings.preferences; |
| 215 | + this.noticeOnly = settings.noticeOnly || ['us']; |
| 216 | + this.supportedLanguages = settings.supportedLanguages || {}; |
215 | 217 | }, |
216 | 218 | (err) => console.error('error loading settings', err) |
217 | 219 | ); |
@@ -337,13 +339,16 @@ class NoticeChoice extends StableSelectorMixin(LitElement) { |
337 | 339 | private _initSettingsAndContent(language: string) { |
338 | 340 | const [lang] = language.split(/[-_]/); |
339 | 341 | const defaultLang = |
340 | | - supportedLanguages(language) || supportedLanguages(lang) || 'en'; |
| 342 | + this.supportedLanguages[language?.toLocaleLowerCase()] || |
| 343 | + this.supportedLanguages[lang?.toLocaleLowerCase()] || |
| 344 | + 'en'; |
341 | 345 |
|
342 | 346 | loadSettings( |
343 | 347 | this.environment, |
344 | 348 | (settings) => { |
345 | 349 | this.countrySettings = settings.preferences; |
346 | 350 | this.noticeOnly = settings.noticeOnly || ['us']; |
| 351 | + this.supportedLanguages = settings.supportedLanguages || {}; |
347 | 352 | }, |
348 | 353 | () => this.defaultLoadSettings() |
349 | 354 | ); |
@@ -519,6 +524,7 @@ class NoticeChoice extends StableSelectorMixin(LitElement) { |
519 | 524 | (countryPreferencesSettings) => { |
520 | 525 | this.countrySettings = countryPreferencesSettings.preferences; |
521 | 526 | this.noticeOnly = countryPreferencesSettings.noticeOnly || ['us']; |
| 527 | + this.supportedLanguages = settings.supportedLanguages || {}; |
522 | 528 | }, |
523 | 529 | (error) => { |
524 | 530 | console.error('error loading content', error); |
|
0 commit comments