Skip to content
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

Fix locale alias by including locale object in MultiSite Context #716

Merged
merged 8 commits into from
Sep 13, 2022

Conversation

adamraya
Copy link
Collaborator

@adamraya adamraya commented Sep 13, 2022

Description

This PR fixes the issue #712.

Problem

The MultiSite refactor to optimize Server-side performance PR #667, introduced a regression where the locale.alias defined in the sites.js configuration is no longer working.

Solution

The implemented solution follows the proposed solution in the issue #712.
The MultiSiteContext now includes the locale object including the locale.id and locale.alias and uses the locale.alias in URLs over the locale.id if the locale.alias is defined in sites.js configuration.

Types of Changes

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Breaking change (could cause existing functionality to not work as expected)
  • Other changes (non-breaking changes that does not fit any of the above)

Breaking changes include:

  • Removing a public function or component or prop
  • Adding a required argument to a function
  • Changing the data type of a function parameter or return value
  • Adding a new peer dependency to package.json

Changes

  • MultiSiteContext includes the locale object.
  • Fixed tests to work with the locale object.
  • Small refactor to re-use code by adding the site utils getSiteByReference.

How to Test-Drive This PR

  1. Add a locale.alias to the packages/template-retail-react-app/config/sites.js configuration.

E.g.

...
l10n: {
            supportedCurrencies: ['GBP', 'EUR', 'CNY', 'JPY'],
            defaultCurrency: 'GBP',
            supportedLocales: [
...
                {
                    id: 'en-GB',
                    preferredCurrency: 'GBP'
                    alias: 'TestLocaleAliasGB' // Locale alias
                },
...
  1. Start the Template Retail React App in the monorepo by running npm run start.

Verify 👇

  • The locale alias defined in the sites.js config file is used in the URLs (Except for the home page).
  • The locale alias is used in the URL when switching locales using the Select component in the Footer.

Checklists

General

  • Changes are covered by test cases
  • CHANGELOG.md updated with a short description of changes (not required for documentation updates)

Accessibility Compliance

You must check off all items in one of the follow two lists:

  • There are no changes to UI

or...

Localization

  • Changes include a UI text update in the Retail React App (which requires translation)

@adamraya adamraya requested a review from a team as a code owner September 13, 2022 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants