Skip to content

feat: Handle config from path locales strategy - #3141

Merged
hellofanny merged 2 commits into
feat/multilanguagefrom
feat/path-locales
Dec 3, 2025
Merged

hellofanny merged 2 commits into
feat/multilanguagefrom
feat/path-locales

Conversation

@hellofanny

@hellofanny hellofanny commented Dec 3, 2025 •

Copy link
Copy Markdown
Contributor

What's the purpose of this pull request?

  • Adds SDK payload temp to test
    The locales-setting.json is a temp file that mocks the payload that the faststore-sdk will return with the account's available locales and settings.
  • Handle config from path locales strategy: extract available locales from locales-setting.json

How it works?

Set next.config.js to support url Path locales, cases like https://www.store.com/en-CA, https://www.store.com/pt-BR

How to test it?

  1. Run the application locally
  2. When navigating to http://localhost:3000 the defaultLocale should be set.
  • check the <html lang> attribute. It should be pt-BR
image
  1. Then, try navigating to other mapped locales, and check the lang atribute.
image image

All the paths listed above should be valid paths.

Starters Deploy Preview

References

Jira Task
https://nextjs.org/docs/pages/guides/internationalization

defaultLocale: storeConfig.session.locale,
locales: Object.keys(localesSettings.locales),
defaultLocale: localesSettings.defaultLocale,
localeDetection: false,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disabling Automatic Locale Detection because we aren't going to deal with it now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: just out of curiosity, is it something we will do in a future phase of multilang or we haven't considered it yet?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

according to the PDR, is nice to have, so we probably will handle in the future!

@hellofanny hellofanny changed the title Feat/path locales feat: Handle config from path locales strategy Dec 3, 2025
@codesandbox-ci

codesandbox-ci Bot commented Dec 3, 2025

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@hellofanny
hellofanny marked this pull request as ready for review December 3, 2025 12:51
@hellofanny
hellofanny requested a review from a team as a code owner December 3, 2025 12:51
@hellofanny
hellofanny requested review from eduardoformiga and renatomaurovtex and removed request for a team December 3, 2025 12:51
@hellofanny hellofanny self-assigned this Dec 3, 2025
@hellofanny hellofanny added the enhancement New feature or request label Dec 3, 2025
@hellofanny
hellofanny merged commit caec9db into feat/multilanguage Dec 3, 2025
@hellofanny
hellofanny deleted the feat/path-locales branch December 3, 2025 18:10
lemagnetic added a commit that referenced this pull request Mar 5, 2026
## What's the purpose of this pull request?

Removing hardcoded labels:
- #3099
- #3102 
- #3107 
- #3104 
- #3103 
- #3125
- #3131
- #3116
- #3142
- #3192

Setting Up locales
- #3141
- #3143
- #3147
- #3156
- #3162
- #3145
- #3164
- #3169
- #3171
- #3176
- #3180
- #3169
 custom path
- #3185
- #3162
- #3156
- #3170

Components
- #3093
- #3175

Fetching content 

- #3165

Others
- #3176
- #3171
- #3181
- #3189
- #3205


## How to test locally?
- Run `pnpm I` (install all the new dependencies and needed packages)
- If you want to try localization feature, go
to`/discovery.config.default.js`:
Enable localization:
```
localization: {
  enabled: true
}
```
- Run `node packages/cli/bin/run.js generate-i18n ./packages/core` to
fetch the bindings

If the contentSource is not set to content platform yet, you will see a
message to update to it.
>   contentSource: {
>     type: 'CP',
>   },

⚠️ Note: Ensure the url is set to localhost for local testing. These
locale bindings are generated in `discovery.config` after running the
generate-i18n command.

```diff
localization: {
  enabled: true,
  defaultLocale: 'en-US',
   regions: {...},
    locales: {
      'pt-BR': {
           ...
        bindings: [
          {
            currencyCode: 'BRL',
-           url: 'https://brandless.fast.store/pt-BR',
+           url: 'http://localhost:3000/pt-BR',
            salesChannel: '2',
            isDefault: true,
            locales: [
              {
                code: 'pt-BR',
                isDefault: true,
              },
            ],
          },
        ],
      },
      'it-IT': {
        ...
        bindings: [
          {
            currencyCode: 'EUR',
-           url: 'https://brandless.fast.store/it-IT',
+           url: 'http://localhost:3000/it-IT',
            salesChannel: '3',
            isDefault: true,
            locales: [
              {
                code: 'it-IT',
                isDefault: true,
              },
            ],
          },
          {
            currencyCode: 'EUR',
-           url: 'https://brandless.fast.store/europe/it',
+           url: 'http://localhost:3000/europe/it',
            salesChannel: '3',
            isDefault: false,
            locales: [
              {
                code: 'it-IT',
                isDefault: true,
              },
            ],
          },
        ],
      },
      'en-US': {
        code: 'en-US',
        name: 'English',
        languageCode: 'en',
        languageName: 'English',
        script: 'Latn',
        textDirection: 'ltr',
        regionCode: 'US',
        bindings: [
          {
            currencyCode: 'USD',
-           url: 'https://brandless.fast.store',
+           url: 'http://localhost:3000,
            salesChannel: '1',
            isDefault: true,
            locales: [
              {
                code: 'en-US',
                isDefault: true,
              },
            ],
          },
        ],
      },
    ...
}
```

- Go to /packages/core and run `npmn dev`

---------

Co-authored-by: Larícia Mota <[email protected]>
Co-authored-by: Leandro Rodrigues <[email protected]>
Co-authored-by: Otavio Moreira Meirelles <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants