Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksnyder committed Dec 5, 2023
1 parent 252d719 commit b07437f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 34 deletions.
46 changes: 25 additions & 21 deletions v2/goi18n/main.go
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
// Command goi18n manages message files used by the i18n package.
//
// go get -u github.com/nicksnyder/go-i18n/v2/goi18n
// goi18n -help
// go get -u github.com/nicksnyder/go-i18n/v2/goi18n
// goi18n -help
//
// Use `goi18n extract` to create a message file that contains the messages defined in your Go source files.
// # en.toml
// [PersonCats]
// description = "The number of cats a person has"
// one = "{{.Name}} has {{.Count}} cat."
// other = "{{.Name}} has {{.Count}} cats."
//
// # en.toml
// [PersonCats]
// description = "The number of cats a person has"
// one = "{{.Name}} has {{.Count}} cat."
// other = "{{.Name}} has {{.Count}} cats."
//
// Use `goi18n merge` to create message files for translation.
// # translate.es.toml
// [PersonCats]
// description = "The number of cats a person has"
// hash = "sha1-f937a0e05e19bfe6cd70937c980eaf1f9832f091"
// one = "{{.Name}} has {{.Count}} cat."
// other = "{{.Name}} has {{.Count}} cats."
//
// # translate.es.toml
// [PersonCats]
// description = "The number of cats a person has"
// hash = "sha1-f937a0e05e19bfe6cd70937c980eaf1f9832f091"
// one = "{{.Name}} has {{.Count}} cat."
// other = "{{.Name}} has {{.Count}} cats."
//
// Use `goi18n merge` to merge translated message files with your existing message files.
// # active.es.toml
// [PersonCats]
// description = "The number of cats a person has"
// hash = "sha1-f937a0e05e19bfe6cd70937c980eaf1f9832f091"
// one = "{{.Name}} tiene {{.Count}} gato."
// other = "{{.Name}} tiene {{.Count}} gatos."
//
// # active.es.toml
// [PersonCats]
// description = "The number of cats a person has"
// hash = "sha1-f937a0e05e19bfe6cd70937c980eaf1f9832f091"
// one = "{{.Name}} tiene {{.Count}} gato."
// other = "{{.Name}} tiene {{.Count}} gatos."
//
// Load the active messages into your bundle.
// bundle.RegisterUnmarshalFunc("toml", toml.Unmarshal)
// bundle.MustLoadMessageFile("active.es.toml")
//
// bundle.RegisterUnmarshalFunc("toml", toml.Unmarshal)
// bundle.MustLoadMessageFile("active.es.toml")
package main

import (
Expand Down
1 change: 1 addition & 0 deletions v2/i18n/bundlefs.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build go1.16
// +build go1.16

package i18n
Expand Down
30 changes: 17 additions & 13 deletions v2/i18n/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,27 @@
// according to a set of locale preferences.
//
// Create a Bundle to use for the lifetime of your application.
// bundle := i18n.NewBundle(language.English)
//
// bundle := i18n.NewBundle(language.English)
//
// Load translations into your bundle during initialization.
// bundle.LoadMessageFile("en-US.yaml")
//
// bundle.LoadMessageFile("en-US.yaml")
//
// Create a Localizer to use for a set of language preferences.
// func(w http.ResponseWriter, r *http.Request) {
// lang := r.FormValue("lang")
// accept := r.Header.Get("Accept-Language")
// localizer := i18n.NewLocalizer(bundle, lang, accept)
// }
//
// func(w http.ResponseWriter, r *http.Request) {
// lang := r.FormValue("lang")
// accept := r.Header.Get("Accept-Language")
// localizer := i18n.NewLocalizer(bundle, lang, accept)
// }
//
// Use the Localizer to lookup messages.
// localizer.MustLocalize(&i18n.LocalizeConfig{
// DefaultMessage: &i18n.Message{
// ID: "HelloWorld",
// Other: "Hello World!",
// },
// })
//
// localizer.MustLocalize(&i18n.LocalizeConfig{
// DefaultMessage: &i18n.Message{
// ID: "HelloWorld",
// Other: "Hello World!",
// },
// })
package i18n

0 comments on commit b07437f

Please sign in to comment.