-
Notifications
You must be signed in to change notification settings - Fork 15
MWPW-185900: refactor locales structure #552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch.
Commits
|
npeltier
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- code feedbacks are mostly comments
- expected results in tests things i actually request to change
io/www/src/fragment/locales.js
Outdated
| regionLocalesCache[cacheKey] = LOCALES.filter((locale) => | ||
| isRegionLocale(locale, surface, language, includeDefault), | ||
| ).sort((a, b) => getCountryName(a.country).localeCompare(getCountryName(b.country))); | ||
| const [lang, country] = localeCode.split('_'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i know it's a simple operation, but i would still factorize localeCode -> [lang, country] code somewhere in this file (you are using it l423 too)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
| function getCorrespondingLocale(surface, locale) { | ||
| const defaultLocale = getDefaultLocaleCode(surface, locale); | ||
| return defaultLocale || locale; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we remove this, and just use getDefaultLocaleCode? to me that corresponding wording (i created) just introduces confusion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, i just need to test it via customized method then
reason why i kept this method was that its easy for unit test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
| }); | ||
| }); | ||
|
|
||
| it('should return 503 if language is not supported', async function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, it should return 400 or 403 depending how we want to phrase it, but it's not a server error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
| const locale = getCorrespondingLocale('zh_TW'); | ||
| expect(locale).to.equal('zh_TW'); | ||
| describe('corresponding locale corner case', function () { | ||
| it('locale with no default should be returned as is', async function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assuming we remove getCorrespondingLocale and just keep default one. I think we should in here just return null: there is not default locale for bb_BB
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
| @@ -19,14 +19,10 @@ export class EditorContextStore extends ReactiveStore { | |||
| if (!fragmentPath) return { isVariation: false, defaultLocale: null }; | |||
| const pathMatch = fragmentPath.match(/\/content\/dam\/mas\/[^/]+\/([^/]+)\//); | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could probably extract logic from io/www fetchFragment here too
| handleMenuOpen() { | ||
| this.updateComplete.then(() => { | ||
| const search = this.shadowRoot.querySelector('sp-search'); | ||
| if (search) { | ||
| search.focus(); | ||
| } | ||
| }); | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not related to that PR but ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was hard to test it without this :D
npeltier
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm
| return { status, message }; | ||
| } | ||
| const baseFragment = skimFragmentFromReferences(body); | ||
| //todo check |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should add more details to this todo
Resolves MWPW-185900
Locale changes in Studio & /mas/io
In acom and express
To retest in Studio:
Top nav, placeholders & creation of regional variations.
Test URLs Studio:
en_GB&acom (sandbox,nala) - becomes 'default lang'
pt_BR&acom - becomes 'default lang'
pt_PT&acom - becomes 'default lang'
pt_PT&ccd - stay 'variation lang' of pt_BR
corner case - variation language fr_LU&acom:
Test URLs /mas/io:
CCD gallery (Nala rules are same as acom)
There is not content in en_GB, so before it was falling back to en_US. Now its a default language so it will 404.
en_IN and en_AU fallback to en_GB, so 404
https://main--mas--adobecom.aem.live/web-components/docs/ccd.html?locale=en_IN&mas-io-url=https://14257-merchatscale-3ch023.adobeioruntime.net/api/v1/web/MerchAtScale
https://main--mas--adobecom.aem.live/web-components/docs/ccd.html?locale=en_AU&mas-io-url=https://14257-merchatscale-3ch023.adobeioruntime.net/api/v1/web/MerchAtScale
en_KW falls back to en_US, so 200
https://main--mas--adobecom.aem.live/web-components/docs/ccd.html?locale=en_KW&mas-io-url=https://14257-merchatscale-3ch023.adobeioruntime.net/api/v1/web/MerchAtScale
corner case - bu_BU unexisting locale - 404