-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Add translation plugin #5385
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
Add translation plugin #5385
Conversation
Inject `translation` function into all components that require localization. Built-in support for English (default) and Russian. Support for custom localization via `translations` config option. Add lint rule to avoid naked strings in react components. Should fix swagger-api#2488
@shockey This seems to be exactly what I need for my application. In a globalized age we can not expect every user to understand english. Would it be possible to get this merged soon? |
Hello, any chance to see this merged? |
Hi, when can we expect to see this merge? |
@AlexMayants Thanks for the PR! It is very comprehensive. However, such a translation plugin should be an independent and separately maintained project from the SwaggerUI. |
@tim-lai I see your point. However, I'm not sure how to implement such a plugin without recreating a large percentage of SwaggerUI components. It seems to me that SwaggerUI should provide at least some way to alter localizable values: via config, maybe. Could you suggest a way to approach this? |
Really disappointing to see this getting closed. Not everyone speaks english. |
Hi. It is not more elegant, but I think is fastest way to do this. The concept is: To do this, we need to include:
4-translate.js that makes translation (example https://drive.google.com/file/d/1FkpAXV1oOpA4-VxrrHBABHBxkZTveTkI/view?usp=sharing ...we need to add all the other translation code) Jquery initialize keeps listening when a specific element is load Here my actual code of translate.js like in downloaded file
In this case we listen for example when .opblock-title is loaded and find span to replace text using json file. I need help to find all section to translate (we can use old swagger-ui 2.x translation files to have example of section to translate?) and than I can use the same method used in the translate.js example to complete this file PS: if you use last swashbucke .net core, you need to:
3-inject js files in swaggerui configuration in startup.cs
|
Description
Inject
translate
function into all components that require localization.Built-in support for English (default) and Russian.
Support for custom localization via
translations
config option.Add lint rule to avoid naked (untranslated) strings in react components.
Added configuration options:
translations
,translationLanguage
,defaultTranslationLanguage
.Motivation and Context
Fixes #2488
How Has This Been Tested?
All existing tests are in the green.
Screenshots (if appropriate):
Checklist
My PR contains...
src/
is unmodified: changes to documentation, CI, metadata, etc.)package.json
)My changes...
Documentation
Automated tests