| 1 |
// Package i18n provides support for looking up messages |
| 2 |
// according to a set of locale preferences. |
| 3 |
// |
| 4 |
// Create a Bundle to use for the lifetime of your application. |
| 5 |
// |
| 6 |
// bundle := i18n.NewBundle(language.English) |
| 7 |
// |
| 8 |
// Load translations into your bundle during initialization. |
| 9 |
// |
| 10 |
// bundle.LoadMessageFile("en-US.yaml") |
| 11 |
// |
| 12 |
// Create a Localizer to use for a set of language preferences. |
| 13 |
// |
| 14 |
// func(w http.ResponseWriter, r *http.Request) { |
| 15 |
// lang := r.FormValue("lang") |
| 16 |
// accept := r.Header.Get("Accept-Language") |
| 17 |
// localizer := i18n.NewLocalizer(bundle, lang, accept) |
| 18 |
// } |
| 19 |
// |
| 20 |
// Use the Localizer to lookup messages. |
| 21 |
// |
| 22 |
// localizer.MustLocalize(&i18n.LocalizeConfig{ |
| 23 |
// DefaultMessage: &i18n.Message{ |
| 24 |
// ID: "HelloWorld", |
| 25 |
// Other: "Hello World!", |
| 26 |
// }, |
| 27 |
// }) |
| 28 |
package i18n |