Skip to content

Commit 4c18349

Browse files
committed
Supporting Qatar Arabic language
1 parent 7d1522f commit 4c18349

3 files changed

Lines changed: 16 additions & 52 deletions

File tree

packages/web-components/src/components/notice-choice/__stories__/notice-choice.stories.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ const questionChoices = {
2020
};
2121
const languages = {
2222
'English [en]': 'en',
23-
'Arabic [ar]': 'ar',
23+
'Arabic [ar]': 'ar',
24+
'Arabic (Qatar) [qa-ar]': 'qa-ar',
2425
'Chinese (PRC) [zh-cn]': 'zh-cn',
2526
'Chinese (Taiwan) [zh-tw]': 'zh-tw',
2627
'French [fr]': 'fr',

packages/web-components/src/components/notice-choice/notice-choice.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@
1010
import { loadContent, loadSettings, checkEmailStatus } from './services';
1111
import { html, LitElement } from 'lit';
1212
import { property } from 'lit/decorators.js';
13-
import {
14-
pwsValueMap,
15-
resetToWorldWideContent,
16-
supportedLanguages,
17-
} from './utils';
13+
import { pwsValueMap, resetToWorldWideContent } from './utils';
1814
import settings from '@carbon/ibmdotcom-utilities/es/utilities/settings/settings.js';
1915
import StableSelectorMixin from '../../globals/mixins/stable-selector';
2016
import styles from './notice-choice.scss';
@@ -161,6 +157,9 @@ class NoticeChoice extends StableSelectorMixin(LitElement) {
161157
@property({ reflect: true })
162158
hiddenPhone = '';
163159

160+
@property({ type: Object, attribute: false })
161+
supportedLanguages = {};
162+
164163
connectedCallback() {
165164
super.connectedCallback();
166165
this._initSettingsAndContent(this.language);
@@ -203,15 +202,18 @@ class NoticeChoice extends StableSelectorMixin(LitElement) {
203202
/[-_]/
204203
)[0];
205204
const supportedLang =
206-
supportedLanguages(this.language) ||
207-
supportedLanguages(langPart) ||
205+
(this.language &&
206+
this.supportedLanguages[this.language?.toLowerCase()]) ||
207+
(langPart && this.supportedLanguages[langPart?.toLowerCase()]) ||
208208
'en';
209209

210210
this.isLoading = true;
211211
loadSettings(
212212
this.environment,
213213
(settings) => {
214214
this.countrySettings = settings.preferences;
215+
this.noticeOnly = settings.noticeOnly || ['us'];
216+
this.supportedLanguages = settings.supportedLanguages || {};
215217
},
216218
(err) => console.error('error loading settings', err)
217219
);
@@ -337,13 +339,16 @@ class NoticeChoice extends StableSelectorMixin(LitElement) {
337339
private _initSettingsAndContent(language: string) {
338340
const [lang] = language.split(/[-_]/);
339341
const defaultLang =
340-
supportedLanguages(language) || supportedLanguages(lang) || 'en';
342+
this.supportedLanguages[language?.toLocaleLowerCase()] ||
343+
this.supportedLanguages[lang?.toLocaleLowerCase()] ||
344+
'en';
341345

342346
loadSettings(
343347
this.environment,
344348
(settings) => {
345349
this.countrySettings = settings.preferences;
346350
this.noticeOnly = settings.noticeOnly || ['us'];
351+
this.supportedLanguages = settings.supportedLanguages || {};
347352
},
348353
() => this.defaultLoadSettings()
349354
);
@@ -519,6 +524,7 @@ class NoticeChoice extends StableSelectorMixin(LitElement) {
519524
(countryPreferencesSettings) => {
520525
this.countrySettings = countryPreferencesSettings.preferences;
521526
this.noticeOnly = countryPreferencesSettings.noticeOnly || ['us'];
527+
this.supportedLanguages = settings.supportedLanguages || {};
522528
},
523529
(error) => {
524530
console.error('error loading content', error);

packages/web-components/src/components/notice-choice/utils.ts

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -55,46 +55,3 @@ export function pwsValueMap(value) {
5555
}[value] || null
5656
);
5757
}
58-
59-
export function supportedLanguages(language) {
60-
const languageMapping = {
61-
en: 'en',
62-
fr: 'fr',
63-
'zh-cn': 'zh-cn',
64-
zh: 'zh-cn',
65-
de: 'de',
66-
id: 'id',
67-
it: 'it',
68-
ja: 'ja',
69-
ko: 'ko',
70-
pt: 'pt',
71-
'es-la': 'es-la',
72-
es: 'es',
73-
ar: 'ar',
74-
'zh-tw': 'zh-tw',
75-
'es-es': 'es',
76-
el: 'el',
77-
hu: 'hu',
78-
he: 'he',
79-
ms: 'ms',
80-
pl: 'pl',
81-
sl: 'sl',
82-
tr: 'tr',
83-
uk: 'uk',
84-
bg: 'bg',
85-
cs: 'cs',
86-
da: 'da',
87-
et: 'et',
88-
fi: 'fi',
89-
hr: 'hr',
90-
lt: 'lt',
91-
lv: 'lv',
92-
nl: 'nl',
93-
no: 'no',
94-
ro: 'ro',
95-
sk: 'sk',
96-
sr: 'sr',
97-
vi: 'vi',
98-
};
99-
return languageMapping[language.toLocaleLowerCase()];
100-
}

0 commit comments

Comments
 (0)