Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

I18n (internationalisation) support #249

Closed
stanislas-m opened this issue Feb 15, 2017 · 4 comments
Closed

I18n (internationalisation) support #249

stanislas-m opened this issue Feb 15, 2017 · 4 comments

Comments

@stanislas-m
Copy link
Member

stanislas-m commented Feb 15, 2017

As a plugin / module, I think we can provide a way to manage translations.

Common solutions:

  • GNU gettext with po/pot/mo files
  • ini files
  • yaml or json files
@u007
Copy link
Member

u007 commented Mar 8, 2017

will this help?
https://gist.github.com/u007/fda1dd4f92f424242732b5f7a82d5fc3

i think it needs to have the files in config/locales/* in watch

it seems to be not so good, because i need to detect language from header, anyone have any suggestion?

@stanislas-m
Copy link
Member Author

@u007 Hum, if you look at the comments in the code:

// Use Tfunc or MustTfunc to fetch a TranslateFunc that will return the translated string for a specific language.
//     func handleRequest(w http.ResponseWriter, r *http.Request) {
//         cookieLang := r.Cookie("lang")
//         acceptLang := r.Header.Get("Accept-Language")
//         defaultLang = "en-US"  // known valid language
//         T, err := i18n.Tfunc(cookieLang, acceptLang, defaultLang)
//         fmt.Println(T("Hello world"))
//     }

I think it just have to be called like this in a custom middleware.

@markbates
Copy link
Member

We also need to think about, make sure, that translation files get bundled into the binary that is built.

@u007
Copy link
Member

u007 commented Mar 9, 2017

ive done fix in the gist, made a middleware to setup velvet with context
and pass shared i18n setup to another sub directory so it can be shared among actions

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants