swagger-ui
swagger-ui copied to clipboard
[improvement] Translation: automatic and manual language selection
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:
-
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.) -
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: -
End user should be able to change the language using
swagger-ui
.
Additional information: swagger-ui version affected: commit 1f2a5d7 swagger file: not required
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
My solution is different. My focus is on providing multilingual schema instead of simply translating those labels/buttons which I considered less important. Detail please check issue #7917
up
Looking for some direction here: what would be the correct approach to provide translations for the text that is generated by swagger-ui?
I'm using some unpleasant CSS hacks to work around the issue now, but would much prefer doing this a cleaner way. Our team might be able to help submit a PR for such this change.