комментарии и сообщения переведены на английский

- комментарии, тексты ошибок, вывод CLI и сообщения тестов теперь на английском
- по-русски остались только литералы словаря ru и содержимое фикстур: это
  данные под проверкой, а не текст инструмента
- согласование числительных в итоге упростилось до английского plural
This commit is contained in:
av
2026-07-27 10:04:27 +03:00
parent 0b8cc125b3
commit b2d07ae55d
17 changed files with 548 additions and 524 deletions
+16 -28
View File
@@ -16,8 +16,8 @@ import (
func runSuiteCheck(env Env, args []string) ExitCode {
fs := flag.NewFlagSet("convy suite check", flag.ContinueOnError)
fs.SetOutput(env.Err)
root := fs.String("root", "", "корень набора; по умолчанию ищется вверх от текущей директории")
quiet := fs.Bool("quiet", false, "печатать только находки")
root := fs.String("root", "", "root of the suite; by default it is looked up upwards from the current directory")
quiet := fs.Bool("quiet", false, "print findings only")
if err := fs.Parse(args); err != nil {
return Usage
}
@@ -27,9 +27,9 @@ func runSuiteCheck(env Env, args []string) ExitCode {
found, err := manifest.Find(env.Dir)
if err != nil {
if errors.Is(err, manifest.ErrNotFound) {
fmt.Fprintf(env.Err, "здесь не набор конвенций: рядом и выше нет %s\n", manifest.Name)
fmt.Fprintf(env.Err, "not a conventions suite: no %s here or above\n", manifest.Name)
if _, err := os.Stat(filepath.Join(env.Dir, ".conventions.toml")); err == nil {
fmt.Fprintln(env.Err, "это проект — проверка того, что здесь, называется \"convy check\"")
fmt.Fprintln(env.Err, "this is a project — checking what is here is called \"convy check\"")
}
return Usage
}
@@ -68,7 +68,7 @@ func printReport(w io.Writer, rep *check.Report, s *suite.Suite, quiet bool) {
if f.Line > 0 {
where = fmt.Sprintf(":%d", f.Line)
}
fmt.Fprintf(w, " %s%s %s [%s]\n", label(f.Severity), where, f.Msg, f.Family)
fmt.Fprintf(w, " %s%s %s [%s]\n", f.Severity, where, f.Msg, f.Family)
}
if quiet {
@@ -77,36 +77,24 @@ func printReport(w io.Writer, rep *check.Report, s *suite.Suite, quiet bool) {
if len(findings) > 0 {
fmt.Fprintln(w)
}
fmt.Fprintf(w, "набор: %s, %s, версия языка %d (%s)\n",
plural(len(s.Docs), "файл", "файла", "файлов"),
plural(len(s.Manifest.LiveTopics()), "тема", "темы", "тем"),
fmt.Fprintf(w, "suite: %s, %s, language version %d (%s)\n",
plural(len(s.Docs), "file"),
plural(len(s.Manifest.LiveTopics()), "topic"),
s.Manifest.Language.Version, s.Manifest.Language.Lang)
switch {
case rep.Errors() > 0:
fmt.Fprintf(w, "ошибок: %d, предупреждений: %d\n", rep.Errors(), rep.Warnings())
fmt.Fprintf(w, "errors: %d, warnings: %d\n", rep.Errors(), rep.Warnings())
case rep.Warnings() > 0:
fmt.Fprintf(w, "ошибок нет, предупреждений: %d\n", rep.Warnings())
fmt.Fprintf(w, "no errors, warnings: %d\n", rep.Warnings())
default:
fmt.Fprintln(w, "целостность набора в порядке")
fmt.Fprintln(w, "suite integrity holds")
}
}
// plural согласует существительное с числом: 1 файл, 2 файла, 5 файлов.
func plural(n int, one, few, many string) string {
word := many
switch {
case n%100 >= 11 && n%100 <= 14:
case n%10 == 1:
word = one
case n%10 >= 2 && n%10 <= 4:
word = few
// plural agrees a noun with a count: 1 file, 4 files.
func plural(n int, noun string) string {
if n == 1 {
return fmt.Sprintf("%d %s", n, noun)
}
return fmt.Sprintf("%d %s", n, word)
}
func label(s check.Severity) string {
if s == check.Warning {
return "предупреждение"
}
return "ошибка"
return fmt.Sprintf("%d %ss", n, noun)
}