1 package flect 2 3 import ( 4 "strings" 5 ) 6 7 // Humanize returns first letter of sentence capitalized. 8 // Common acronyms are capitalized as well. 9 // Other capital letters in string are left as provided. 10 // employee_salary = Employee salary 11 // employee_id = employee ID 12 // employee_mobile_number = Employee mobile number 13 // first_Name = First Name 14 // firstName = First Name 15 func Humanize(s string) string { 16 return New(s).Humanize().String() 17 } 18 19 // Humanize First letter of sentence capitalized 20 func (i Ident) Humanize() Ident { 21 if len(i.Original) == 0 { 22 return New("") 23 } 24 25 parts := xappend([]string{}, Titleize(i.Parts[0])) 26 if len(i.Parts) > 1 { 27 parts = xappend(parts, i.Parts[1:]...) 28 } 29 30 return New(strings.Join(parts, " ")) 31 } 32