Skip to content

Commit

Permalink
Fix Japanese translation of max-items, lt-items and lte-items error (#…
Browse files Browse the repository at this point in the history
…1250)

## Fixes
In English version, max-items error message is `"{0} must contain at
maximum {1}"`.
([ref](https://github.com/go-playground/validator/blob/master/translations/en/en.go#L292))
And current Japanese translation `"{0}は最大でも{1}を含まなければなりません"` is strait
translation of English version but quite unnatural for Japanese.

We don’t usually use a sentence like `"含まなければなりません"` ("must contain") in
this context. Because it can not **"contain"** any items further. So, we
simply say `"{0}は最大でも{1}でなければなりません"` ("{0} must be at maximum {1}")
instead.

`"lt-items"` and `"lte-items"` messages have same issue as above. (if
those errors occur, it can not contain any items further as well.)

---

**Make sure that you've checked the boxes below before you submit PR:**
- [x] Tests exist or have been written that cover this particular
change.

@go-playground/validator-maintainers
  • Loading branch information
Tomoki108 authored Jun 1, 2024
1 parent d3e28c4 commit 3d65a9b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions translations/ja/ja.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er
return
}

if err = ut.Add("max-items", "{0}は最大でも{1}を含まなければなりません", false); err != nil {
if err = ut.Add("max-items", "{0}は最大でも{1}でなければなりません", false); err != nil {
return
}
// if err = ut.AddCardinal("max-items-item", "{0}つの項目", locales.PluralRuleOne, false); err != nil {
Expand Down Expand Up @@ -405,7 +405,7 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er
return
}

if err = ut.Add("lt-items", "{0}は{1}よりも少ない項目を含まなければなりません", false); err != nil {
if err = ut.Add("lt-items", "{0}は{1}よりも少ない項目でなければなりません", false); err != nil {
return
}

Expand Down Expand Up @@ -525,7 +525,7 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er
return
}

if err = ut.Add("lte-items", "{0}は最大でも{1}を含まなければなりません", false); err != nil {
if err = ut.Add("lte-items", "{0}は最大でも{1}でなければなりません", false); err != nil {
return
}

Expand Down
6 changes: 3 additions & 3 deletions translations/ja/ja_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ func TestTranslations(t *testing.T) {
},
{
ns: "Test.LteMultiple",
expected: "LteMultipleは最大でも2つの項目を含まなければなりません",
expected: "LteMultipleは最大でも2つの項目でなければなりません",
},
{
ns: "Test.LteTime",
Expand All @@ -534,7 +534,7 @@ func TestTranslations(t *testing.T) {
},
{
ns: "Test.LtMultiple",
expected: "LtMultipleは2つの項目よりも少ない項目を含まなければなりません",
expected: "LtMultipleは2つの項目よりも少ない項目でなければなりません",
},
{
ns: "Test.LtTime",
Expand Down Expand Up @@ -574,7 +574,7 @@ func TestTranslations(t *testing.T) {
},
{
ns: "Test.MaxMultiple",
expected: "MaxMultipleは最大でも7つの項目を含まなければなりません",
expected: "MaxMultipleは最大でも7つの項目でなければなりません",
},
{
ns: "Test.MinString",
Expand Down

0 comments on commit 3d65a9b

Please sign in to comment.