say: one count rule everywhere, and a page she can explain (V-521)

The PR 113 review found four defects in one line file. Swept the other four
families and the Go side for the same four.

The JSON was clean: no undeclared placeholder, no abbreviation spoken, no
single-variant entry left unfixed. One register leak — page_blocked read
"robots.txt" out loud, which is a filename, not a reason he can act on.

The count rule was not clean. Four more copies of the three-way agreement
existed and two of them were wrong: ruPlural produced «1 минут назад» and
«5 часа назад» because formatTime spelled the noun out. pluralTasksRU was a
fifth copy. All of them now call say.CountWord. The pending-notification
summary picks the whole phrase, because the adjective declines with the noun.
This commit is contained in:
2026-08-04 16:47:23 +04:00
parent 12c18dcf65
commit 6fba4d6931
7 changed files with 30 additions and 44 deletions
+1 -1
View File
@@ -79,7 +79,7 @@ var queryFloor = map[string]string{
QueryFactValue: "у меня записано: {key} — {value}",
QueryFound: "вот что я нашла: {text}",
QueryPageText: "вот что на странице: {text}",
QueryPageBlocked: "эта страница закрыта для чтения — robots.txt не разрешает.",
QueryPageBlocked: "эта страница закрыта для чтения — сам сайт это запрещает.",
QueryPageEmpty: "страница открылась, но читать там нечего.",
QueryFeedsOff: "ленты не настроены.",
QueryFeedsNew: "вот что нового: {items}",
+1 -1
View File
@@ -38,7 +38,7 @@
},
"page_blocked": {
"fixed": true,
"variants": ["эта страница закрыта для чтения — robots.txt не разрешает."]
"variants": ["эта страница закрыта для чтения — сам сайт это запрещает."]
},
"page_empty": {
"fixed": true,
+1 -15
View File
@@ -263,21 +263,7 @@ func joinRU(rs []Ranked, limit int, withReasons bool) string {
s := strings.Join(parts, "; ")
if rest > 0 {
// With the noun. Spoken, a bare number trails off mid-sentence.
s += fmt.Sprintf("; и ещё %d %s", rest, pluralTasksRU(rest))
s += fmt.Sprintf("; и ещё %d %s", rest, say.CountWord(rest, "задача", "задачи", "задач"))
}
return s
}
// pluralTasksRU — the right form of "задача" for a count. Russian needs three.
func pluralTasksRU(n int) string {
if n%100 >= 11 && n%100 <= 14 {
return "задач"
}
switch n % 10 {
case 1:
return "задача"
case 2, 3, 4:
return "задачи"
}
return "задач"
}
+4 -2
View File
@@ -4,6 +4,8 @@ import (
"strings"
"testing"
"time"
"github.com/kami/maven/internal/say"
)
func at(y int, m time.Month, d int) *time.Time {
@@ -240,8 +242,8 @@ func TestFormatRUTailCarriesTheNoun(t *testing.T) {
t.Errorf("reply = %q, want the count with its noun", got)
}
for n, want := range map[int]string{1: "задача", 2: "задачи", 5: "задач", 11: "задач", 21: "задача"} {
if got := pluralTasksRU(n); got != want {
t.Errorf("pluralTasksRU(%d) = %q, want %q", n, got, want)
if got := say.CountWord(n, "задача", "задачи", "задач"); got != want {
t.Errorf("CountWord(%d) = %q, want %q", n, got, want)
}
}
}