From 3c4ec90a895ec21a331b536980fa47798965c02c Mon Sep 17 00:00:00 2001 From: mathuria Date: Thu, 25 May 2023 11:09:22 +0530 Subject: [PATCH 01/16] MWPW-125482 Provoding an option to override default textdirection --- libs/utils/utils.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/utils/utils.js b/libs/utils/utils.js index 6637b39612..0c5ed6fb2f 100644 --- a/libs/utils/utils.js +++ b/libs/utils/utils.js @@ -151,7 +151,8 @@ export const [setConfig, getConfig] = (() => { config.autoBlocks = conf.autoBlocks ? [...AUTO_BLOCKS, ...conf.autoBlocks] : AUTO_BLOCKS; document.documentElement.setAttribute('lang', config.locale.ietf); try { - document.documentElement.setAttribute('dir', (new Intl.Locale(config.locale.ietf)).textInfo.direction); + const contentDir = getMetadata('content-direction')?.toLowerCase(); + document.documentElement.setAttribute('dir', contentDir || config.locale.dir || 'ltr'); } catch (e) { // eslint-disable-next-line no-console console.log('Invalid or missing locale:', e); From f5694872a46d4d6563cbad733e9cd77c17ee1d9f Mon Sep 17 00:00:00 2001 From: mathuria Date: Thu, 25 May 2023 11:12:04 +0530 Subject: [PATCH 02/16] MWPW-125482 Provoding an option to override default textdirection --- libs/utils/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/utils/utils.js b/libs/utils/utils.js index 0c5ed6fb2f..f6934e76b4 100644 --- a/libs/utils/utils.js +++ b/libs/utils/utils.js @@ -151,7 +151,7 @@ export const [setConfig, getConfig] = (() => { config.autoBlocks = conf.autoBlocks ? [...AUTO_BLOCKS, ...conf.autoBlocks] : AUTO_BLOCKS; document.documentElement.setAttribute('lang', config.locale.ietf); try { - const contentDir = getMetadata('content-direction')?.toLowerCase(); + const contentDir = getMetadata('content-direction'); document.documentElement.setAttribute('dir', contentDir || config.locale.dir || 'ltr'); } catch (e) { // eslint-disable-next-line no-console From 05b79631224f3bad0ed6ca401d81368187b056a4 Mon Sep 17 00:00:00 2001 From: Aishwarya Mathuria Date: Thu, 25 May 2023 11:48:08 +0530 Subject: [PATCH 03/16] Update utils.test.js --- test/utils/utils.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/utils/utils.test.js b/test/utils/utils.test.js index 39162276c5..6904af5ffb 100644 --- a/test/utils/utils.test.js +++ b/test/utils/utils.test.js @@ -255,7 +255,7 @@ describe('Utils', () => { it('Gracefully dies when locale ietf is missing and dir is not set.', () => { setConfigWithPath('/ua/solutions'); - expect(document.documentElement.getAttribute('dir')).null; + expect(document.documentElement.getAttribute('dir')).to.equal('ltr'); }); }); From 0c185d422556ad5b3e977b5f9ea7c405dd3a847a Mon Sep 17 00:00:00 2001 From: Aishwarya Mathuria Date: Thu, 25 May 2023 12:06:14 +0530 Subject: [PATCH 04/16] Update scripts.js --- libs/scripts/scripts.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/scripts/scripts.js b/libs/scripts/scripts.js index 996daf4323..24cbfa8a88 100644 --- a/libs/scripts/scripts.js +++ b/libs/scripts/scripts.js @@ -75,10 +75,10 @@ const locales = { bg: { ietf: 'bg-BG', tk: 'aaz7dvd.css' }, ru: { ietf: 'ru-RU', tk: 'aaz7dvd.css' }, ua: { ietf: 'uk-UA', tk: 'aaz7dvd.css' }, - il_he: { ietf: 'he', tk: 'nwq1mna.css' }, - ae_ar: { ietf: 'ar', tk: 'nwq1mna.css' }, - mena_ar: { ietf: 'ar', tk: 'dis2dpj.css' }, - sa_ar: { ietf: 'ar', tk: 'nwq1mna.css' }, + il_he: { ietf: 'he', tk: 'nwq1mna.css', dir: 'rtl' }, + ae_ar: { ietf: 'ar', tk: 'nwq1mna.css', dir: 'rtl' }, + mena_ar: { ietf: 'ar', tk: 'dis2dpj.css', dir: 'rtl' }, + sa_ar: { ietf: 'ar', tk: 'nwq1mna.css', dir: 'rtl' }, // Asia Pacific au: { ietf: 'en-AU', tk: 'pps7abe.css' }, hk_en: { ietf: 'en-HK', tk: 'pps7abe.css' }, From afabef2d2353805914966a9a32e39b2891281100 Mon Sep 17 00:00:00 2001 From: Aishwarya Mathuria Date: Thu, 25 May 2023 12:09:13 +0530 Subject: [PATCH 05/16] Update utils.test.js --- test/utils/utils.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/utils/utils.test.js b/test/utils/utils.test.js index 6904af5ffb..f987773712 100644 --- a/test/utils/utils.test.js +++ b/test/utils/utils.test.js @@ -229,8 +229,8 @@ describe('Utils', () => { config.locales = { '': { ietf: 'en-US', tk: 'hah7vzn.css' }, africa: { ietf: 'en', tk: 'pps7abe.css' }, - il_he: { ietf: 'he', tk: 'nwq1mna.css' }, - mena_ar: { ietf: 'ar', tk: 'dis2dpj.css' }, + il_he: { ietf: 'he', tk: 'nwq1mna.css', dir: 'rtl' }, + mena_ar: { ietf: 'ar', tk: 'dis2dpj.css', dir: 'rtl' }, ua: { tk: 'aaz7dvd.css' }, }; }); From 007121082bf6239fe719db4b4c8f65736bc1a427 Mon Sep 17 00:00:00 2001 From: Aishwarya Mathuria Date: Thu, 25 May 2023 12:27:32 +0530 Subject: [PATCH 06/16] Update scripts.js --- libs/scripts/scripts.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/scripts/scripts.js b/libs/scripts/scripts.js index 24cbfa8a88..996daf4323 100644 --- a/libs/scripts/scripts.js +++ b/libs/scripts/scripts.js @@ -75,10 +75,10 @@ const locales = { bg: { ietf: 'bg-BG', tk: 'aaz7dvd.css' }, ru: { ietf: 'ru-RU', tk: 'aaz7dvd.css' }, ua: { ietf: 'uk-UA', tk: 'aaz7dvd.css' }, - il_he: { ietf: 'he', tk: 'nwq1mna.css', dir: 'rtl' }, - ae_ar: { ietf: 'ar', tk: 'nwq1mna.css', dir: 'rtl' }, - mena_ar: { ietf: 'ar', tk: 'dis2dpj.css', dir: 'rtl' }, - sa_ar: { ietf: 'ar', tk: 'nwq1mna.css', dir: 'rtl' }, + il_he: { ietf: 'he', tk: 'nwq1mna.css' }, + ae_ar: { ietf: 'ar', tk: 'nwq1mna.css' }, + mena_ar: { ietf: 'ar', tk: 'dis2dpj.css' }, + sa_ar: { ietf: 'ar', tk: 'nwq1mna.css' }, // Asia Pacific au: { ietf: 'en-AU', tk: 'pps7abe.css' }, hk_en: { ietf: 'en-HK', tk: 'pps7abe.css' }, From 846c0148a4503636e43436267bb412c5184d5948 Mon Sep 17 00:00:00 2001 From: Aishwarya Mathuria Date: Thu, 25 May 2023 12:29:57 +0530 Subject: [PATCH 07/16] Update scripts.js --- libs/scripts/scripts.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/scripts/scripts.js b/libs/scripts/scripts.js index 996daf4323..24cbfa8a88 100644 --- a/libs/scripts/scripts.js +++ b/libs/scripts/scripts.js @@ -75,10 +75,10 @@ const locales = { bg: { ietf: 'bg-BG', tk: 'aaz7dvd.css' }, ru: { ietf: 'ru-RU', tk: 'aaz7dvd.css' }, ua: { ietf: 'uk-UA', tk: 'aaz7dvd.css' }, - il_he: { ietf: 'he', tk: 'nwq1mna.css' }, - ae_ar: { ietf: 'ar', tk: 'nwq1mna.css' }, - mena_ar: { ietf: 'ar', tk: 'dis2dpj.css' }, - sa_ar: { ietf: 'ar', tk: 'nwq1mna.css' }, + il_he: { ietf: 'he', tk: 'nwq1mna.css', dir: 'rtl' }, + ae_ar: { ietf: 'ar', tk: 'nwq1mna.css', dir: 'rtl' }, + mena_ar: { ietf: 'ar', tk: 'dis2dpj.css', dir: 'rtl' }, + sa_ar: { ietf: 'ar', tk: 'nwq1mna.css', dir: 'rtl' }, // Asia Pacific au: { ietf: 'en-AU', tk: 'pps7abe.css' }, hk_en: { ietf: 'en-HK', tk: 'pps7abe.css' }, From 90b4bf228e62e1e7cfd343e38428975ee8a01d6e Mon Sep 17 00:00:00 2001 From: Aishwarya Mathuria Date: Thu, 25 May 2023 12:45:04 +0530 Subject: [PATCH 08/16] Adding fallback to intl obj --- libs/utils/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/utils/utils.js b/libs/utils/utils.js index f6934e76b4..4f917ca635 100644 --- a/libs/utils/utils.js +++ b/libs/utils/utils.js @@ -152,7 +152,7 @@ export const [setConfig, getConfig] = (() => { document.documentElement.setAttribute('lang', config.locale.ietf); try { const contentDir = getMetadata('content-direction'); - document.documentElement.setAttribute('dir', contentDir || config.locale.dir || 'ltr'); + document.documentElement.setAttribute('dir', contentDir || config.locale.dir || (new Intl.Locale(config.locale.ietf)).textInfo.direction); } catch (e) { // eslint-disable-next-line no-console console.log('Invalid or missing locale:', e); From 8c58acb0caceece29a57962d12d35ea1284ea90f Mon Sep 17 00:00:00 2001 From: Aishwarya Mathuria Date: Thu, 25 May 2023 12:45:41 +0530 Subject: [PATCH 09/16] Update utils.test.js --- test/utils/utils.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/utils/utils.test.js b/test/utils/utils.test.js index f987773712..0befc4e1c7 100644 --- a/test/utils/utils.test.js +++ b/test/utils/utils.test.js @@ -255,7 +255,7 @@ describe('Utils', () => { it('Gracefully dies when locale ietf is missing and dir is not set.', () => { setConfigWithPath('/ua/solutions'); - expect(document.documentElement.getAttribute('dir')).to.equal('ltr'); + expect(document.documentElement.getAttribute('dir')).null; }); }); From df6b1dc7b8c5a40bdc75a37b2de15b08fb75c658 Mon Sep 17 00:00:00 2001 From: mathuria Date: Thu, 25 May 2023 20:08:21 +0530 Subject: [PATCH 10/16] Removing Intl --- libs/utils/utils.js | 2 +- test/utils/utils.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/utils/utils.js b/libs/utils/utils.js index 4f917ca635..f6934e76b4 100644 --- a/libs/utils/utils.js +++ b/libs/utils/utils.js @@ -152,7 +152,7 @@ export const [setConfig, getConfig] = (() => { document.documentElement.setAttribute('lang', config.locale.ietf); try { const contentDir = getMetadata('content-direction'); - document.documentElement.setAttribute('dir', contentDir || config.locale.dir || (new Intl.Locale(config.locale.ietf)).textInfo.direction); + document.documentElement.setAttribute('dir', contentDir || config.locale.dir || 'ltr'); } catch (e) { // eslint-disable-next-line no-console console.log('Invalid or missing locale:', e); diff --git a/test/utils/utils.test.js b/test/utils/utils.test.js index 0befc4e1c7..13768274a2 100644 --- a/test/utils/utils.test.js +++ b/test/utils/utils.test.js @@ -255,7 +255,7 @@ describe('Utils', () => { it('Gracefully dies when locale ietf is missing and dir is not set.', () => { setConfigWithPath('/ua/solutions'); - expect(document.documentElement.getAttribute('dir')).null; + expect(document.documentElement.getAttribute('dir')).to.equal('ltr');; }); }); From 62c62a1e502734c116108160a6fe316b31047335 Mon Sep 17 00:00:00 2001 From: mathuria Date: Thu, 25 May 2023 20:08:34 +0530 Subject: [PATCH 11/16] Removing Intl --- test/utils/utils.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/utils/utils.test.js b/test/utils/utils.test.js index 13768274a2..f987773712 100644 --- a/test/utils/utils.test.js +++ b/test/utils/utils.test.js @@ -255,7 +255,7 @@ describe('Utils', () => { it('Gracefully dies when locale ietf is missing and dir is not set.', () => { setConfigWithPath('/ua/solutions'); - expect(document.documentElement.getAttribute('dir')).to.equal('ltr');; + expect(document.documentElement.getAttribute('dir')).to.equal('ltr'); }); }); From f1b727970b185bf21aea42f793776990357806e1 Mon Sep 17 00:00:00 2001 From: mathuria Date: Fri, 26 May 2023 01:55:59 +0530 Subject: [PATCH 12/16] Adding Intl --- libs/utils/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/utils/utils.js b/libs/utils/utils.js index f6934e76b4..923a137af0 100644 --- a/libs/utils/utils.js +++ b/libs/utils/utils.js @@ -152,7 +152,7 @@ export const [setConfig, getConfig] = (() => { document.documentElement.setAttribute('lang', config.locale.ietf); try { const contentDir = getMetadata('content-direction'); - document.documentElement.setAttribute('dir', contentDir || config.locale.dir || 'ltr'); + document.documentElement.setAttribute('dir', contentDir || config.locale.dir || Intl.Locale(config.locale.ietf))?.textInfo?.direction || 'ltr'); } catch (e) { // eslint-disable-next-line no-console console.log('Invalid or missing locale:', e); From 04f292f47ed712068f124949047f872639a56938 Mon Sep 17 00:00:00 2001 From: mathuria Date: Fri, 26 May 2023 01:58:49 +0530 Subject: [PATCH 13/16] Adding Intl --- libs/utils/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/utils/utils.js b/libs/utils/utils.js index 923a137af0..b39fc234c8 100644 --- a/libs/utils/utils.js +++ b/libs/utils/utils.js @@ -152,7 +152,7 @@ export const [setConfig, getConfig] = (() => { document.documentElement.setAttribute('lang', config.locale.ietf); try { const contentDir = getMetadata('content-direction'); - document.documentElement.setAttribute('dir', contentDir || config.locale.dir || Intl.Locale(config.locale.ietf))?.textInfo?.direction || 'ltr'); + document.documentElement.setAttribute('dir', contentDir || config.locale.dir || Intl.Locale(config.locale.ietf)?.textInfo?.direction || 'ltr'); } catch (e) { // eslint-disable-next-line no-console console.log('Invalid or missing locale:', e); From 7599435860cf6add46e8049024ec2feaa3c9fe89 Mon Sep 17 00:00:00 2001 From: mathuria Date: Fri, 26 May 2023 02:02:22 +0530 Subject: [PATCH 14/16] Adding Intl --- libs/utils/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/utils/utils.js b/libs/utils/utils.js index b39fc234c8..522387658f 100644 --- a/libs/utils/utils.js +++ b/libs/utils/utils.js @@ -152,7 +152,7 @@ export const [setConfig, getConfig] = (() => { document.documentElement.setAttribute('lang', config.locale.ietf); try { const contentDir = getMetadata('content-direction'); - document.documentElement.setAttribute('dir', contentDir || config.locale.dir || Intl.Locale(config.locale.ietf)?.textInfo?.direction || 'ltr'); + document.documentElement.setAttribute('dir', contentDir || config.locale.dir || new Intl.Locale(config.locale.ietf)?.textInfo?.direction || 'ltr'); } catch (e) { // eslint-disable-next-line no-console console.log('Invalid or missing locale:', e); From 6edbc0697baa0cef3de9af06a780a233fbf5e8d1 Mon Sep 17 00:00:00 2001 From: mathuria Date: Fri, 26 May 2023 02:11:10 +0530 Subject: [PATCH 15/16] Adding text fix --- test/utils/utils.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/utils/utils.test.js b/test/utils/utils.test.js index f987773712..0befc4e1c7 100644 --- a/test/utils/utils.test.js +++ b/test/utils/utils.test.js @@ -255,7 +255,7 @@ describe('Utils', () => { it('Gracefully dies when locale ietf is missing and dir is not set.', () => { setConfigWithPath('/ua/solutions'); - expect(document.documentElement.getAttribute('dir')).to.equal('ltr'); + expect(document.documentElement.getAttribute('dir')).null; }); }); From 9fc5f7277d407b312981e6f37ef97a8aeca8b1ff Mon Sep 17 00:00:00 2001 From: mathuria Date: Fri, 26 May 2023 15:08:27 +0530 Subject: [PATCH 16/16] Adding check for config.locale.ietf to get default ltr --- libs/utils/utils.js | 2 +- test/utils/utils.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/utils/utils.js b/libs/utils/utils.js index 522387658f..10e9df0513 100644 --- a/libs/utils/utils.js +++ b/libs/utils/utils.js @@ -152,7 +152,7 @@ export const [setConfig, getConfig] = (() => { document.documentElement.setAttribute('lang', config.locale.ietf); try { const contentDir = getMetadata('content-direction'); - document.documentElement.setAttribute('dir', contentDir || config.locale.dir || new Intl.Locale(config.locale.ietf)?.textInfo?.direction || 'ltr'); + document.documentElement.setAttribute('dir', contentDir || config.locale.dir || (config.locale.ietf ? (new Intl.Locale(config.locale.ietf)?.textInfo?.direction) : null) || 'ltr'); } catch (e) { // eslint-disable-next-line no-console console.log('Invalid or missing locale:', e); diff --git a/test/utils/utils.test.js b/test/utils/utils.test.js index 0befc4e1c7..f987773712 100644 --- a/test/utils/utils.test.js +++ b/test/utils/utils.test.js @@ -255,7 +255,7 @@ describe('Utils', () => { it('Gracefully dies when locale ietf is missing and dir is not set.', () => { setConfigWithPath('/ua/solutions'); - expect(document.documentElement.getAttribute('dir')).null; + expect(document.documentElement.getAttribute('dir')).to.equal('ltr'); }); });