From 3d65a9bbe91e69261d4878325833ed73cc94fc27 Mon Sep 17 00:00:00 2001 From: Tomoki Nagata <45285704+Tomoki108@users.noreply.github.com> Date: Sat, 1 Jun 2024 23:50:41 +0900 Subject: [PATCH] Fix Japanese translation of max-items, lt-items and lte-items error (#1250) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 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 --- translations/ja/ja.go | 6 +++--- translations/ja/ja_test.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/translations/ja/ja.go b/translations/ja/ja.go index dea083ac6..898828396 100644 --- a/translations/ja/ja.go +++ b/translations/ja/ja.go @@ -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 { @@ -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 } @@ -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 } diff --git a/translations/ja/ja_test.go b/translations/ja/ja_test.go index afb507a21..6df52d32a 100644 --- a/translations/ja/ja_test.go +++ b/translations/ja/ja_test.go @@ -518,7 +518,7 @@ func TestTranslations(t *testing.T) { }, { ns: "Test.LteMultiple", - expected: "LteMultipleは最大でも2つの項目を含まなければなりません", + expected: "LteMultipleは最大でも2つの項目でなければなりません", }, { ns: "Test.LteTime", @@ -534,7 +534,7 @@ func TestTranslations(t *testing.T) { }, { ns: "Test.LtMultiple", - expected: "LtMultipleは2つの項目よりも少ない項目を含まなければなりません", + expected: "LtMultipleは2つの項目よりも少ない項目でなければなりません", }, { ns: "Test.LtTime", @@ -574,7 +574,7 @@ func TestTranslations(t *testing.T) { }, { ns: "Test.MaxMultiple", - expected: "MaxMultipleは最大でも7つの項目を含まなければなりません", + expected: "MaxMultipleは最大でも7つの項目でなければなりません", }, { ns: "Test.MinString",