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

Setting the language to 'en' using the create-sitecore-jss CLI, causes a duplicate locale error. #1591

Closed
liznelson opened this issue Aug 16, 2023 · 2 comments
Labels
backlog Issue/PR/discussion is reviewed and added to backlog for the further work 🐞 bug stale

Comments

@liznelson
Copy link

Describe the Bug

When using the create-sitecore-jss cli to stand up a starter app, setting the language to 'en' causes a duplicate locale error that causes the site build to fail.

throw new Error(`Specified i18n.locales contains the following duplicate locales:\n` + `${[
 ^Error: Specified i18n.locales contains the following duplicate locales: en 
  Each locale should be listed only once.

The source of this error seems to be in packages/create-sitecore-jss/src/templates/nextjs-styleguide/src/lib/next-config/plugins/styleguide.js. The cli defined language is added with templating but there is no filter if the input is 'en'.
This is the file code.

const styleguidePlugin = (nextConfig = {}) => {
  return Object.assign({}, nextConfig, {
    i18n: {
      ...nextConfig.i18n,
      locales: ['en', '<%- language %>'], 
    },
  });
};

To Reproduce

Install the starter template with style guide and define the language as -en.

npx create-sitecore-jss 
  --templates nextjs,nextjs-sxa,nextjs-styleguide,nextjs-styleguide-tracking 
  --appName locale-bug-repro 
  --fetchWith GraphQL 
  --prerender SSR 
  --language en 

Try building the application, you can use next:dev or one of the sitecore starting scripts.

You will see an error about duplicate locales. When inspecting the /lib/next-config/plugins/styleguide.js file, you will see
locales: ['en', 'en'].

Expected Behavior

The language is filtered if 'en'.

Possible Fix

No response

Provide environment information

  • Sitecore Version:
  • JSS Version: 21.2.4
  • Browser Name and version:
  • Operating System and version (desktop or mobile):
  • Link to your project (if available):
@illiakovalenko illiakovalenko added the backlog Issue/PR/discussion is reviewed and added to backlog for the further work label Sep 12, 2023
@illiakovalenko
Copy link
Contributor

@liznelson Thanks for the detailed information. We have a ticket in our internal backlog and will work on this issue

Copy link

stale bot commented Sep 13, 2024

This has been automatically marked as stale because it has not had recent activity. It will be closed if there is no further activity within 30 days. You may add comments or the 'keep' label to prevent it from closing. Thank you for your contributions.

@stale stale bot added the stale label Sep 13, 2024
@stale stale bot closed this as completed Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Issue/PR/discussion is reviewed and added to backlog for the further work 🐞 bug stale
Projects
None yet
Development

No branches or pull requests

2 participants