How change language in Swagger-UI using Swashbuckle

5.2k Views Asked by At

How change language to pt-br in Swagger-UI using Swashbuckle?

I'm add in SwaggerConfig:

 .EnableSwaggerUi(c =>
                {
                    c.InjectJavaScript(Assembly.GetExecutingAssembly(), "{appnamespace}.Content.js.translator.js", false);
                    c.InjectJavaScript(Assembly.GetExecutingAssembly(), "{appnamespace}.Content.js.pt.js", false);
                });
1

There are 1 best solutions below

1
On

It works to me according to the documentation, in ASP.NET Core, for example, you must add the path in InjectOnCompleteJavaScript method.

c.InjectOnCompleteJavaScript("/swagger/lang/translator.js");
c.InjectOnCompleteJavaScript("/swagger/lang/custom.js");

The custom.js is my customized file obtained by swagger UI em production according to the path of the swagger UI in your application. My file is custom because I've executed window.SwaggerTranslator.translate() after learn method has been executed.