Skip to content

feat: Add feature flag to enable/disable multilanguage - #3171

Merged
lemagnetic merged 3 commits into
feat/multilanguagefrom
feat/multilanguage-flag
Jan 19, 2026
Merged

lemagnetic merged 3 commits into
feat/multilanguagefrom
feat/multilanguage-flag

Conversation

@lemagnetic

@lemagnetic lemagnetic commented Jan 12, 2026 •

Copy link
Copy Markdown
Contributor

What's the purpose of this pull request?

Adds a feature flag to enable localization functionality.

How it works?

This PR introduces a localization.enabled feature flag in the discovery.config file that controls localization functionality:

  • When localization.enabled === true:

    • The generate-i18n command is executed during build/dev time to retrieve settings from the FastStore SDK
    • Store settings (locale, currency, region, channel) are initialized using data from the SDK
    • The useLocaleValidation hook runs in _app.tsx to validate locale bindings
  • When localization.enabled === false or the flag is missing (default behavior):

    • The generate-i18n command is skipped during build/dev
    • Store settings use static values from discovery.config (session: currency, locale, channel)
    • The useLocaleValidation hook is skipped
    • Backward compatibility is fully maintained

Implementation details:

  • Added localization.enabled: false flag in discovery.config.default.js
  • Modified build.ts and dev.ts commands to conditionally execute generate-i18n
  • Updated useLocaleValidation hook to check the flag before running validation
  • Extracted islocalizationEnabled utility function to packages/cli/src/utils/config.ts for reusability

How to test it?

Note: These instructions refer to testing FastStore within a store.

Example: Brandless store (our test store for multi-language)

Test with localization enabled:

  1. Install the package generated by codesandbox:

    "@faststore/cli": "https://pkg.csb.dev/vtex/faststore/commit/bf4e9e5a/@faststore/cli"
  2. Add the flag to your discovery.config.js:

    localization: {
      enabled: true,
    },
  3. Ensure you have VTEX credentials set (VTEX_ACCOUNT, FS_DISCOVERY_APP_KEY, FS_DISCOVERY_APP_TOKEN)

  4. Run the build or dev command:

    yarn build
    # or
    yarn dev
  5. Verify that:

    • generate-i18n command is executed

Test with localization disabled (default behavior):

  1. Install the package generated by codesandbox:

    "@faststore/cli": "https://pkg.csb.dev/vtex/faststore/commit/bf4e9e5a/@faststore/cli"
  2. Either don't add the flag, or explicitly set:

    localization: {
      enabled: false,
    },
  3. Run the build or dev command:

    yarn build
    # or
    yarn dev
  4. Verify that:

    • generate-i18n command is NOT executed
    • Store uses static session settings from discovery.config
    • No locale validation errors occur

Starters Deploy Preview

N/A

References

Conditionally enable multilanguage features based on multilanguage.enabled flag.
Maintains backward compatibility with default behavior.
@codesandbox-ci

codesandbox-ci Bot commented Jan 12, 2026 •

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.

@lemagnetic
lemagnetic marked this pull request as ready for review January 13, 2026 14:07
@lemagnetic
lemagnetic requested a review from a team as a code owner January 13, 2026 14:07
@lemagnetic
lemagnetic requested review from lariciamota and ommeirelles and removed request for a team January 13, 2026 14:07
@coderabbitai

coderabbitai Bot commented Jan 14, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

enabled: false,
},

// Default cart

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.

@lemagnetic shouldn't we remove the current i18n settings that is in this file?

// i18n: generated by the CLI

  i18n: {
    defaultLocale: 'pt-BR', 
   ...}

@lemagnetic
lemagnetic merged commit a8f8f30 into feat/multilanguage Jan 19, 2026
@lemagnetic
lemagnetic deleted the feat/multilanguage-flag branch January 19, 2026 19:35
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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants