As suggested here names of people should be capitalized like John William Smith
.
I'm writing a small software in Golang which gets last and first name from user's form inputs.
Until Go 1.18 I was using:
lastname = strings.Title(strings.ToLower(strings.TrimSpace(lastname)))
firstname = strings.Title(strings.ToLower(strings.TrimSpace(firstname)))
It works but now Go 1.18 has deprecated strings.Title()
.
They suggest to use golang.org/x/text/cases
instead.
So I think I should change my code in something like this:
caser := cases.Title(language.Und)
lastname = caser.Title(strings.ToLower(strings.TrimSpace(lastname)))
firstname = caser.Title(strings.ToLower(strings.TrimSpace(firstname)))
It works the same as before.
The difference is for Dutch word like ijsland
that should be titled as IJsland
and not Ijsland
.
The question
In the line caser := cases.Title(language.Und)
I'm using Und
because I don't know what language Tag to use.
Should I use language.English
or language.AmericanEnglish
or other?
So far it was like strings.Title()
was using Und
or English
?