swagger-ui localization

1,570 views
Skip to first unread message

Feorlen

unread,
Dec 6, 2016, 5:25:23 PM12/6/16
to Swagger
I have a copy of one of the samples set up on my webserver, so I have swagger-ui working locally. I see many sets of language files in /lang that look like they are for its own strings, but I can't figure out how to actually change the language it serves. 

I have two different browsers with other languages set as primary, but for Swagger I only get pages in English. They are served non-English pages from other sites, so I know that is working. How do I access the localized UI? And how can I make my own localized versions of my API docs?

Thanks!

Meera nyjen

unread,
Dec 8, 2016, 10:49:14 AM12/8/16
to swagger-sw...@googlegroups.com
In index.hml, available in 'dist' folder, below scripts can be used for changing the language. 

 <script src='lang/translator.js' type='text/javascript'></script>
<script src='lang/ru.js' type='text/javascript'></script>

'ru.js' displays the page in russian.

Try with different js files available in 'lang' folder to display in other languages. 

Hope this helps

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Feorlen

unread,
Dec 8, 2016, 12:26:16 PM12/8/16
to Swagger
On Thursday, December 8, 2016 at 7:49:14 AM UTC-8, mvn wrote:
In index.hml, available in 'dist' folder, below scripts can be used for changing the language. 

 <script src='lang/translator.js' type='text/javascript'></script>
<script src='lang/ru.js' type='text/javascript'></script>

I tried this, but I'm getting unexpected results. Do you use one language only?

Starting with a browser configured with "Italian", "English (United States)", and "English" in that order (Chrome isn't letting me remove either English), this is what I'm seeing:  

If I have it only, I get Italian.
If I have it and es, in that order, I get Spanish
If I have it, es, and en, in that order, I get English. 

If I go to a page I know is localized, Google for example, I see Italian. 

Is this what should happen? I would like to be able to offer users content in their own language rather than one I choose for them. 

Feorlen

unread,
Dec 8, 2016, 12:30:48 PM12/8/16
to Swagger


On Thursday, December 8, 2016 at 9:26:16 AM UTC-8, Feorlen wrote:
If I have it only, I get Italian.
If I have it and es, in that order, I get Spanish
If I have it, es, and en, in that order, I get English. 

 Looks like it's serving whichever is last. If I change it to it, en, es, I get Spanish. That's useful to know, but there should be a way for the user to see their own language. My browser isn't even configured for Spanish, yet I'm getting it. 

Meera nyjen

unread,
Dec 8, 2016, 12:51:40 PM12/8/16
to swagger-sw...@googlegroups.com
You can add only one of the language files available in lang folder to index.html. There is no effect if you include more than one language file. It will serve only one 'js' file. 




Reply all
Reply to author
Forward
0 new messages