Swashbuckle.WebApi icon indicating copy to clipboard operation
Swashbuckle.WebApi copied to clipboard

Language file doesn't work

Open fenomeno83 opened this issue 4 years ago • 1 comments

Hi. I need to translate swagger ui in italian.

I've swashbucle 5.1 in .net core 3.1 project.

I've download translator.js and it.js from here https://github.com/swagger-api/swagger-ui/tree/1f2a5d7dd74131f0e9886b0f137ac20165aa90d2/dist/lang

Then I've create a wwwroot folder in my project (because missing and need to put static files)

Then I've enabled static files in startup

app.UseStaticFiles();

I've put the 2 files inside wwwroot folder and addes in startup

       app.UseSwaggerUI(c =>
        {
            
            c.SwaggerEndpoint("/swagger/v1/swagger.json", "Public API");

            c.HeadContent = "<script src='./translator.js'></script><script src='./it.js'></script>";


            c.RoutePrefix = string.Empty;
        });

When i start application, index,html has included script and they are correctly downloaded Here the head part of generated index.html

  <!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Swagger UI</title>
  <link rel="stylesheet" type="text/css" href="./swagger-ui.css">
  <link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
  <link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
  <style>

    html {
        box-sizing: border-box;
        overflow: -moz-scrollbars-vertical;
        overflow-y: scroll;
    }

    *,
    *:before,
    *:after {
        box-sizing: inherit;
    }

    body {
        margin: 0;
        background: #fafafa;
    }
</style>
<script src='./translator.js'></script><script src='./it.js'></script>

But page is not translated.

Can you help me?

fenomeno83 avatar Jul 11 '20 17:07 fenomeno83

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

fenomeno83 avatar Jan 22 '21 06:01 fenomeno83