Swagger-ui: [improvement] Translation: automatic and manual language selection

Created on 4 Nov 2016  路  7Comments  路  Source: swagger-api/swagger-ui

Problem description:

https://github.com/swagger-api/swagger-ui/blob/1f2a5d7dd74131f0e9886b0f137ac20165aa90d2/dist/lang/translator.js#L6-L8

* To enable translation you should include one of language-files in your index.html
* after <script src='lang/translator.js' type='text/javascript'></script>.
* For example - <script src='lang/ru.js' type='text/javascript'></script>

This is unacceptable in today's internet. Every end user should see his language.
So:

  1. swagger-ui should provide some query parameter (e.g. lang) to set set user's language and apply corresponding translation. (This is needed for integration purposes.)

  2. If the parameter is not specified, swagger-ui should determine user's language automatically using the following variables (actually, all of them in the specified order) and apply corresponding translation:

    1. navigator.languages
    2. navigator.language
    3. navigator.userLanguage
  3. End user should be able to change the language using swagger-ui.

Additional information:
swagger-ui version affected: commit 1f2a5d7
swagger file: not required

P2 feature 3.x

All 7 comments

Not a fan this idea.
Let me start by saying that english is not my first language, not even my second, and I'm fine with everything (code/programing related) in english ...

This is not an eCommerce platform where we try to reach a wide audience of "low tech" end users, this is a tool for programmers. Anyone using swagger is familiar with basic english like the reserved words of JavaScript.

Swagger UI supported translation (in version 2.x): swagger-ui/dist/lang/translator.js.
And now the lack of translation support is listed as a known issue: swagger-ui/README.md#known-issues

@heldersepu, as far as I understand, you want to say that Swagger UI should not support translation.
I am not going to argue with this, let the maintainers decide. I just want to note that you will not get any worse if translation support will be implemented properly (see item 3 of my suggestion above), you will be able to switch back to English.

When I said "End user should be able to change the language using swagger-ui", I meant he/she should be able to change it once for all. (Technically, the selected language should be remembered, e.g. using a cookie.)

Yes, we do need to support translations, not sure the mentioned approach is the right one. However, we don't have the capacity to implement this right now.

Hi,
Is there any update regarding this issue?

I am integrating Swagger UI (swagger-ui-react) into our company's application and ran into the lack of internationalization support. I think, the library should at least give developers an option to provide translations for static strings which are displayed in the interface. In this case language detection may be left at the discretion of the host application.

How is the problem progressing?
You can first provide a way to extend the language pack, users can implement it themselves.

I've created a my custom solution:
https://github.com/fenomeno83/SwaggerGlobalization

Was this page helpful?
0 / 5 - 0 ratings