Skip to content

npm start support all locale #7377

Closed as not planned
Closed as not planned

Description

@robberphex

Have you read the Contributing Guidelines on issues?

Description

When working at a multilingual docusaurus project, I always switch between npm start and npm start --locale zh-cn.

Could the user just run npm start and let localeDropdown works normally?

Has this been requested on Canny?

No

Motivation

Currently, npm start doesn't work for multi language site. npm run is not a full-version preview.

Could the user just run npm start and let localeDropdown works normally?

API design

No response

Have you tried building it?

No response

Self-service

  • I'd be willing to contribute this feature to Docusaurus myself.

Activity

  1. added
    feature
    status: needs triage
    on May 8, 2022
  2. added
    status: needs more information
    closed: wontfix
    and removed
    status: needs triage
    status: needs more information
    closed: wontfix
    on May 9, 2022
  3. Josh-Cena commented on May 9, 2022

    @Josh-Cena
    Collaborator

    This is a technical limitation. We use Webpack dev server, which only supports one Webpack process per port. I don't have a decisive answer about whether it's possible or not, but I can't think of a possible way to do this.

  4. Josh-Cena commented on May 10, 2022

    @Josh-Cena
    Collaborator

    In order to support this, we need to support:

    • Simultaneously running two SPAs on one port
    • Namespacing the generated files by locale (currently only one set of generated files are output, which is why the build cannot run in parallel either)
    • Possibly other infra changes around paralleling build processes?

    I highly doubt its feasibility and ROI.

  5. added
    domain: dx
    on May 10, 2022
  6. added
    closed: wontfix
    and removed
    status: needs more information
    on Jun 4, 2022
  7. Josh-Cena commented on Jun 4, 2022

    @Josh-Cena
    Collaborator

    Closing because of lack of response and no defense against my challenges.

    I'm not against this feature, but it requires changes too significant to be beneficial. It's probably not useful for most sites, because pages don't interlink between languages that much.

  8. VitaliiKuzennyi commented on Jun 15, 2022

    @VitaliiKuzennyi

    Did I get right, that it is not possible to localize page in different languages and turn between them while working? If so, how does https://docusaurus.io/ work?

  9. Josh-Cena commented on Jun 15, 2022

    @Josh-Cena
    Collaborator

    @VitaliiKuzennyi Each locale is an individual SPA, so in development, you can only start one SPA. During production, we will build all locales one-by-one, and essentially deploy N SPAs where N is the number of locales. When you use the locale dropdown, you are switching between those SPAs, each of them being pretty much ignorant about the state of the other. You can see them as separate sites, essentially, that happen to be deployed under the same URL.

  10. Josh-Cena commented on Jun 15, 2022

    @Josh-Cena
    Collaborator

    If it's important for you to preview both locales at the same time, I suggest you use yarn start for your primary locale, and yarn start --port 3001 --locale zh-Hans for your second locale. You won't get to use the locale dropdown, but at least you can compare them side-by-side.

    Update: both locales will try to write generated files to the same directory, so if you are starting two locales in parallel, you have to change the generated directory of one locale, for example: cross-env DOCUSAURUS_GENERATED_FILES_DIR_NAME=.docusaurus/zh-Hans yarn start --locale zh-Hans --port 3001

  11. VitaliiKuzennyi commented on Jun 15, 2022

    @VitaliiKuzennyi

    @Josh-Cena Thanks for your answer. It`s clear.

  12. VitaliiKuzennyi commented on Jun 27, 2022

    @VitaliiKuzennyi

    If it's important for you to preview both locales at the same time, I suggest you use yarn start for your primary locale, and yarn start --port 3001 --locale zh-Hans for your second locale. You won't get to use the locale dropdown, but at least you can compare them side-by-side.

    Update: both locales will try to write generated files to the same directory, so if you are starting two locales in parallel, you have to change the generated directory of one locale, for example: cross-env DOCUSAURUS_GENERATED_FILES_DIR_NAME=.docusaurus/zh-Hans yarn start --locale zh-Hans --port 3001

    Hi, @Josh-Cena
    Regarding to your update. Is there some documentation about using cross-env. Did I get it right, this can resolve problem of starting project with two localisations available?

  13. Josh-Cena commented on Jun 27, 2022

    @Josh-Cena
    Collaborator

    cross-env is an npm package. In practice, if you are using Unix, you may not install it. I'm only adding this because setting environment variables on Windows is tricky. The main idea is you need to set the DOCUSAURUS_GENERATED_FILES_DIR environment variable.

  14. AntoineGlacet commented on Nov 25, 2025

    @AntoineGlacet

    late to the party on this ticket. This is really making the contribution to multi-language sites tedious. it's also not mentioned clearly in the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    closed: wontfixdomain: dxfeature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions