Files
aego/schema/label.go
T
sanspie f22242e5aa
ci / release (push) Successful in 5m5s
ci-platforms / build (amd64, windows, windows-2022) (push) Skipped
ci-platforms / build (arm64, darwin, macos-15) (push) Skipped
ci-platforms / build (amd64, darwin, macos-15-intel) (push) Skipped
ci / checks (push) Successful in 4m41s
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 7m14s
Stage 11g2–11g3: registry texts, CLI and the site in Russian (D348)
The remaining editor strings and undo step names; component, field, enum, setting, diagnostic and Script API texts under schema.*, enum.*, setting.*, diag.* and api.*; the launcher, the in-game Settings View with a Language setting, the CLI and aego schema show --lang. Every documentation page has a .ru.md translation; the site has a full Russian tree with hreflang, a language switch and ru/llms.txt; aego docs check --lang ru. New doc.tutorial and doc.recipe icons. Fix: an animator restored by a rewind prepares its controller before the replayed step.
2026-10-25 15:31:22 +03:00

49 lines
1.0 KiB
Go

package schema
import (
"strings"
"unicode"
)
// Label is the name the Inspector shows for a field: its DisplayName hint, else the humanized field name.
func Label(fd *FieldDescriptor) string {
if fd.Hints.DisplayName != "" {
return fd.Hints.DisplayName
}
return Humanize(fd.Name)
}
// TypeLabel is the name the editor shows for a component type: its display name, else its full name.
func TypeLabel(td *TypeDescriptor) string {
if td.DisplayName != "" {
return Title(td)
}
return td.FullName
}
// Humanize turns clearColor or clear_color into Clear Color.
func Humanize(s string) string {
rs := []rune(s)
var b strings.Builder
for i, r := range rs {
if r == '_' {
b.WriteByte(' ')
continue
}
if i == 0 {
b.WriteRune(unicode.ToUpper(r))
continue
}
prev := rs[i-1]
var next rune
if i+1 < len(rs) {
next = rs[i+1]
}
if unicode.IsUpper(r) && (unicode.IsLower(prev) || unicode.IsDigit(prev) || (unicode.IsUpper(prev) && unicode.IsLower(next))) {
b.WriteByte(' ')
}
b.WriteRune(r)
}
return b.String()
}