комментарии и сообщения переведены на английский
- комментарии, тексты ошибок, вывод CLI и сообщения тестов теперь на английском - по-русски остались только литералы словаря ru и содержимое фикстур: это данные под проверкой, а не текст инструмента - согласование числительных в итоге упростилось до английского plural
This commit is contained in:
+18
-15
@@ -5,11 +5,13 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Front — шапка файла. Ключей немного и все они плоские, поэтому разбор здесь
|
||||
// свой: тащить YAML ради четырёх строк `ключ: значение` не за что.
|
||||
// Front is the front matter of a file. There are few keys and all of them are
|
||||
// flat, so the parsing is done here: pulling in YAML for four `key: value`
|
||||
// lines earns nothing.
|
||||
//
|
||||
// Ось слоя объявляется здесь ключами lang и stack, а не выводится из пути
|
||||
// (META-38); отсутствие обоих означает базовый слой темы.
|
||||
// The axis of a layer is declared here by the lang and stack keys rather than
|
||||
// derived from the path (META-38); the absence of both means the base layer of
|
||||
// the topic.
|
||||
type Front struct {
|
||||
Topic string
|
||||
Prefix string
|
||||
@@ -17,25 +19,26 @@ type Front struct {
|
||||
Stack string
|
||||
Extends string
|
||||
|
||||
// At — номер строки, на которой объявлен ключ; нужен, чтобы находка
|
||||
// показывала на объявление, а не на начало файла.
|
||||
// At is the line a key was declared on, so a finding can point at the
|
||||
// declaration rather than at the top of the file.
|
||||
At map[string]int
|
||||
// Unknown — ключи, которых модель не знает.
|
||||
// Unknown lists keys the model does not know.
|
||||
Unknown []string
|
||||
// End — номер строки закрывающего разделителя. Тело файла начинается
|
||||
// со следующей.
|
||||
// End is the line of the closing delimiter. The body of the file starts
|
||||
// on the next one.
|
||||
End int
|
||||
// Present — была ли шапка вообще.
|
||||
// Present says whether there was any front matter at all.
|
||||
Present bool
|
||||
}
|
||||
|
||||
// Axis отвечает, объявлена ли у слоя ось. Слой без ключей оси — базовый.
|
||||
// Axis reports whether the layer declares an axis. A layer without one is the
|
||||
// base layer.
|
||||
func (f Front) Axis() bool {
|
||||
return f.Lang != "" || f.Stack != ""
|
||||
}
|
||||
|
||||
// parseFront разбирает шапку из строк файла. Возвращает шапку и номер первой
|
||||
// строки тела.
|
||||
// parseFront parses the front matter out of the file's lines. It returns the
|
||||
// front matter and the number of the first line of the body.
|
||||
func parseFront(lines []string) (Front, int, error) {
|
||||
front := Front{At: make(map[string]int)}
|
||||
if len(lines) == 0 || strings.TrimSpace(lines[0]) != "---" {
|
||||
@@ -55,7 +58,7 @@ func parseFront(lines []string) (Front, int, error) {
|
||||
}
|
||||
key, value, ok := strings.Cut(line, ":")
|
||||
if !ok {
|
||||
return front, num, fmt.Errorf("строка %d шапки не имеет вида «ключ: значение»", num)
|
||||
return front, num, fmt.Errorf("front matter line %d is not of the form \"key: value\"", num)
|
||||
}
|
||||
key = strings.TrimSpace(key)
|
||||
value = strings.TrimSpace(value)
|
||||
@@ -76,5 +79,5 @@ func parseFront(lines []string) (Front, int, error) {
|
||||
front.Unknown = append(front.Unknown, key)
|
||||
}
|
||||
}
|
||||
return front, len(lines) + 1, fmt.Errorf("шапка не закрыта разделителем ---")
|
||||
return front, len(lines) + 1, fmt.Errorf("front matter is not closed by a --- delimiter")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user