swagger-api / swagger-api/swagger-ui

Select language selection that allows loading different schema specification

Open
#7,917 0 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Is your feature request related to a problem?

I am unsure when the i18n feature can be supported and issue #2488 seems pending for a long time.

I wonder translating those label/buttons into different languages is a stronger feature request than loading a different schema file with different languages. For integration & communication purpose, the schema itself is more important to show differently for different languages.

Describe the solution you'd like

The latest lang-selection branch in my fork adds a language selection in Topbar plugin which allows selecting language and pass it as request header when downloading spec. This enables developer to dynamically load different spec for different language.

The setting of the SwaggerUI should be simply as below:

const ui = SwaggerUIBundle({
        lang: 'en_US',
        langs: [
          {
            code: 'en_US',
            name: 'English'
          },
          {
            code: 'zh_CN',
            name: '中文'
          }
        ]
        ...
});

The tapbar is like this:
image

Request to download the spec would add header as x-swagger-spec-lang: zh_CN

Although current implementation does not translate the Swagger UI itself, I think this selection dropdown can be reused for that in the future.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Topbar plugin and SwaggerUIBundle configuration described in the issue, using the referenced lang-selection branch as context. Verify that the language selector accepts the configured languages, updates the selected value, and sends the chosen code as the x-swagger-spec-lang request header when downloading the schema.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.