loic911 / Rest-api-doc

MIT License
21 stars 32 forks source link

How to add i18n to this plugin #34

Closed neoecos closed 9 years ago

neoecos commented 9 years ago

Hi, i was just wondering if there is any way to add i18n to this plugin?

Thank you,

loic911 commented 9 years ago

It's possible with some work in the plugin. But I have no time for that now.

A quick&dirty solution would be to: -buidl your restapidoc.json file with the plugin -create your own i18n files, -to parse the restapidoc.json file, get a copy for each i18n -for each i18n files, replace key with their corresponding value in json -write all these json files

Then you can create a controller method: def lang = params.lang File docFile = new File(params.lang+"_"+grailsApplication.mergedConfig.grails.plugins.restapidoc.outputFileReading ) // ENG_restapidoc.json, FR_restapidoc.json,... render(docFile.text)

The render must be done on restapidoc/grails-app/views/restApiDoc/index.gsp

You could call "/mycontroller/myaction?lang=ENG, ...

neoecos commented 9 years ago

Thank you for the answers.

It's a really cool idea.