josephspurrier / gowebapp

Basic MVC Web Application in Go
MIT License
1.14k stars 197 forks source link

How to add i18n for multiple language. #18

Closed tinhan closed 3 years ago

tinhan commented 8 years ago

Hi i need to add i18n in your example gowebapp How to do that ?

josephspurrier commented 8 years ago

That's a good question. There are a few packages out there that will help with multiple languages. I took a quick look at https://github.com/nicksnyder/go-i18n and it looks pretty solid.

The documentation is a little confusing, but you'll want to create a T() function that is available in your templates. Then you can use the same function on any flash messages. You can have a variable in the config.json that specifies the translation or build in something that changes it dynamically.

Here is basic example: https://github.com/nicksnyder/go-i18n/issues/27#issuecomment-168387906

And more documentation: https://godoc.org/github.com/nicksnyder/go-i18n/i18n

josephspurrier commented 3 years ago

Closing - info provided.