Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
8b7b3cb
Tune the Chinese version of README (#303)
tengqm Oct 5, 2023
5ee16aa
extract: support typed string constants (#304)
hectorj-thetreep Oct 5, 2023
54617ef
Fix Localize regression with empty default message (#305)
KuSh Oct 23, 2023
025ca0c
Export fields in MessageNotFoundErr (#306) (#307)
stephenafamo Nov 18, 2023
2e598a3
Use correct plural forms when merging translations (#309)
stephenafamo Nov 28, 2023
e308da9
Update to CLDR data v44 (#310)
nicksnyder Dec 3, 2023
3570aa7
Remove usage of deprecated io/ioutil and upgrade to Go 1.16 (#308)
stephenafamo Dec 3, 2023
c42df72
Upgrade dependencies and upgrade Go to 1.18 (#311)
nicksnyder Dec 3, 2023
73b9099
Fix Codecov link
nicksnyder Dec 3, 2023
33f0caf
Update .codecov.yml
nicksnyder Dec 3, 2023
589ec0e
Update Codecov action to v3 (#312)
nicksnyder Dec 3, 2023
794ed38
Update .codecov.yml
nicksnyder Dec 3, 2023
b4fe018
use Codecov token
nicksnyder Dec 3, 2023
6f270f3
Create golangci-lint.yml (#313)
nicksnyder Dec 5, 2023
56d59e5
remove .golangci.yml (#314)
nicksnyder Dec 5, 2023
833e5ac
t.Fatal instead of panic in test
nicksnyder Dec 5, 2023
0cc0111
Update .codecov.yml
nicksnyder Dec 5, 2023
5257e26
remove deprecated use of ioutil
nicksnyder Dec 5, 2023
62e3978
Support configurable template parsers (#317)
nicksnyder Jan 31, 2024
f0cd8fa
Remove v2 directory (#318)
nicksnyder Jan 31, 2024
7c6508d
Fix readme links
nicksnyder Jan 31, 2024
521f196
fix typo (#324)
sunxunle Mar 16, 2024
b42d9bd
fallback to empty string message `""` when get nil value (#326)
LemonNekoGH Mar 31, 2024
8f901db
chore: update yaml version (#330)
leverz Aug 16, 2024
1cb10df
fix: option in TextParser is not used (#335)
cazeaux Oct 12, 2024
db4b725
move badges below title
nicksnyder Oct 12, 2024
793d597
Translation disclaimer
nicksnyder Oct 12, 2024
90c2b36
Update golang.org/x/text to v0.19.0
nicksnyder Oct 13, 2024
2a816a8
add number key test
nicksnyder Oct 13, 2024
a6720fa
Upgrade codecov action to v4 (#337)
nicksnyder Oct 13, 2024
1df59d8
Create dependabot.yml
nicksnyder Oct 13, 2024
9a7694c
Bump actions/setup-go from 2 to 5 (#341)
dependabot[bot] Oct 13, 2024
b98c5de
Bump actions/checkout from 1 to 4 (#339)
dependabot[bot] Oct 13, 2024
e163f10
Bump golangci/golangci-lint-action from 3 to 6 (#340)
dependabot[bot] Oct 13, 2024
63bab5c
Bump goreleaser/goreleaser-action from 2 to 6 (#342)
dependabot[bot] Oct 13, 2024
89b95c0
Better build step condition (#344)
nicksnyder Oct 13, 2024
a5d356a
Use stable Go version in all workflows (#343)
nicksnyder Oct 13, 2024
6a4fba6
switch to scip (#345)
nicksnyder Oct 13, 2024
0a3a706
correct report card badge
nicksnyder Oct 13, 2024
af5be8c
Error if reserved message keys are mixed with unreserved keys (#320)
nicksnyder Oct 13, 2024
91c0041
Create README.uk-UA.md (#336)
dejurin Oct 14, 2024
89ed3ee
Bump golang.org/x/text from 0.19.0 to 0.20.0 (#351)
dependabot[bot] Dec 1, 2024
d096e3f
Bump golang.org/x/text from 0.20.0 to 0.21.0 (#354)
dependabot[bot] Jan 1, 2025
711fb20
Add convenience function `MustLocalizeMessage` (#352)
apricotbucket28 Jan 12, 2025
4333871
Fix case sensitivity with message keys (#358)
nicksnyder Feb 2, 2025
fd1f64e
Extract errors for duplicate message ids (#359)
nicksnyder Feb 2, 2025
2bc3536
Go 1.24 and golangci-lint v2.0 (#369)
nicksnyder Apr 5, 2025
ecedc47
chore: fix typo in comment (#365)
luozexuan Apr 5, 2025
5cc59bc
Bump github.com/BurntSushi/toml from 1.4.0 to 1.5.0 (#366)
dependabot[bot] Apr 5, 2025
f877392
CLDR v47 (#370)
nicksnyder Apr 5, 2025
59e9aef
Require go 1.23 (#371)
nicksnyder Apr 5, 2025
6746ef4
Bump golang.org/x/text from 0.21.0 to 0.23.0 (#367)
dependabot[bot] Apr 5, 2025
d14dab6
Bump codecov/codecov-action from 4 to 5 (#350)
dependabot[bot] Apr 5, 2025
0dba9d9
delete broken job
nicksnyder Apr 5, 2025
56f2b4a
delete broken badge
nicksnyder Apr 5, 2025
155d176
go mod tidy
nicksnyder Apr 5, 2025
5b39699
fix typo
nicksnyder Apr 5, 2025
14b4857
Bump golang.org/x/text from 0.23.0 to 0.24.0 (#372)
dependabot[bot] May 2, 2025
465ab3a
Bump golang.org/x/text from 0.24.0 to 0.25.0 (#374)
dependabot[bot] Jun 9, 2025
63241f3
Bump golang.org/x/text from 0.25.0 to 0.26.0 (#377)
dependabot[bot] Jul 1, 2025
2d36d21
Bump golang.org/x/text from 0.26.0 to 0.27.0 (#378)
dependabot[bot] Aug 1, 2025
d21654b
Bump golang.org/x/text from 0.27.0 to 0.28.0 (#380)
dependabot[bot] Sep 2, 2025
28dedbe
Bump golang.org/x/text from 0.28.0 to 0.29.0 (#382)
dependabot[bot] Oct 1, 2025
bc4e523
Merge remote-tracking branch 'nick/main' into sync2022510take2
bep Oct 18, 2025
4d305ee
fork: Update paths
bep Oct 18, 2025
ec001b7
fork: Trim GitHub actions setup
bep Oct 18, 2025
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Create golangci-lint.yml (nicksnyder#313)
  • Loading branch information
nicksnyder authored Dec 5, 2023
commit 6f270f3fe7e49cbef901b9e285fe1dccdaa5321e
25 changes: 25 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: golangci-lint
on:
push:
branches:
- main
pull_request:

permissions:
contents: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.21'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.55
working-directory: v2
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
2 changes: 0 additions & 2 deletions v2/i18n/bundlefs.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// +build go1.16

package i18n

import (
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
9 changes: 0 additions & 9 deletions v2/i18n/localizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,6 @@ func (e *MessageNotFoundErr) Error() string {
return fmt.Sprintf("message %q not found in language %q", e.MessageID, e.Tag)
}

type pluralizeErr struct {
messageID string
tag language.Tag
}

func (e *pluralizeErr) Error() string {
return fmt.Sprintf("unable to pluralize %q because there no plural rule for %q", e.messageID, e.tag)
}

type messageIDMismatchErr struct {
messageID string
defaultMessageID string
Expand Down
6 changes: 0 additions & 6 deletions v2/internal/plural/codegen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,6 @@ func infof(format string, args ...interface{}) {

var verbose bool

func verbosef(format string, args ...interface{}) {
if verbose {
infof(format, args...)
}
}

func fatalf(format string, args ...interface{}) {
infof("fatal: "+format+"\n", args...)
os.Exit(1)
Expand Down
10 changes: 7 additions & 3 deletions v2/internal/plural/codegen/xml.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import (
"regexp"
"strconv"
"strings"

"golang.org/x/text/cases"
"golang.org/x/text/language"
)

// SupplementalData is the top level struct of plural.xml
Expand All @@ -22,7 +25,7 @@ type PluralGroup struct {

// Name returns a unique name for this plural group.
func (pg *PluralGroup) Name() string {
n := strings.Title(pg.Locales)
n := cases.Title(language.AmericanEnglish).String(pg.Locales)
return strings.Replace(n, " ", "", -1)
}

Expand All @@ -39,7 +42,7 @@ type PluralRule struct {

// CountTitle returns the title case of the PluralRule's count.
func (pr *PluralRule) CountTitle() string {
return strings.Title(pr.Count)
return cases.Title(language.AmericanEnglish).String(pr.Count)
}

// Condition returns the condition where the PluralRule applies.
Expand Down Expand Up @@ -100,7 +103,8 @@ func (pr *PluralRule) GoCondition() string {
if parts == nil {
continue
}
lvar, lmod, op, rhs := strings.Title(parts[1]), parts[2], parts[3], strings.TrimSpace(parts[4])
lvar := cases.Title(language.AmericanEnglish).String(parts[1])
lmod, op, rhs := parts[2], parts[3], strings.TrimSpace(parts[4])
if op == "=" {
op = "=="
}
Expand Down
2 changes: 1 addition & 1 deletion v2/internal/plural/rule_gen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ func TestPt(t *testing.T) {
}
}

func TestCaItPt_PTVec(t *testing.T) {
func TestCaItPt_ptVec(t *testing.T) {
var tests []pluralFormTest

tests = appendIntegerTests(tests, One, []string{"1"})
Expand Down