Merge pull request #1241 from cherez/patch-1
Fixed doubled first name in templates
This commit is contained in:
commit
ace3d80e41
@ -24,10 +24,12 @@ public class ContributorDto : IFormattable
|
|||||||
|
|
||||||
//Single-word names parse as first names. Use it as last name.
|
//Single-word names parse as first names. Use it as last name.
|
||||||
var lastName = string.IsNullOrWhiteSpace(HumanName.Last) ? HumanName.First : HumanName.Last;
|
var lastName = string.IsNullOrWhiteSpace(HumanName.Last) ? HumanName.First : HumanName.Last;
|
||||||
|
//Because of the above, if the have only a first name, then we'd double the name as "FirstName FirstName", so clear the first name in that situation.
|
||||||
|
var firstName = string.IsNullOrWhiteSpace(HumanName.Last) ? HumanName.Last : HumanName.First;
|
||||||
|
|
||||||
return format
|
return format
|
||||||
.Replace("{T}", HumanName.Title)
|
.Replace("{T}", HumanName.Title)
|
||||||
.Replace("{F}", HumanName.First)
|
.Replace("{F}", firstName)
|
||||||
.Replace("{M}", HumanName.Middle)
|
.Replace("{M}", HumanName.Middle)
|
||||||
.Replace("{L}", lastName)
|
.Replace("{L}", lastName)
|
||||||
.Replace("{S}", HumanName.Suffix)
|
.Replace("{S}", HumanName.Suffix)
|
||||||
|
|||||||
@ -284,7 +284,7 @@ namespace TemplatesTests
|
|||||||
[DataRow("Carla Naumburg PhD", "Title=, First=Carla, Middle= Last=Naumburg, Suffix=PhD")]
|
[DataRow("Carla Naumburg PhD", "Title=, First=Carla, Middle= Last=Naumburg, Suffix=PhD")]
|
||||||
[DataRow("Doug Stanhope and Friends", "Title=, First=Doug, Middle= Last=Stanhope and Friends, Suffix=")]
|
[DataRow("Doug Stanhope and Friends", "Title=, First=Doug, Middle= Last=Stanhope and Friends, Suffix=")]
|
||||||
[DataRow("Tamara Lovatt-Smith", "Title=, First=Tamara, Middle= Last=Lovatt-Smith, Suffix=")]
|
[DataRow("Tamara Lovatt-Smith", "Title=, First=Tamara, Middle= Last=Lovatt-Smith, Suffix=")]
|
||||||
[DataRow("Common", "Title=, First=Common, Middle= Last=Common, Suffix=")]
|
[DataRow("Common", "Title=, First=, Middle= Last=Common, Suffix=")]
|
||||||
[DataRow("Doug Tisdale Jr.", "Title=, First=Doug, Middle= Last=Tisdale, Suffix=Jr")]
|
[DataRow("Doug Tisdale Jr.", "Title=, First=Doug, Middle= Last=Tisdale, Suffix=Jr")]
|
||||||
[DataRow("Robert S. Mueller III", "Title=, First=Robert, Middle=S. Last=Mueller, Suffix=III")]
|
[DataRow("Robert S. Mueller III", "Title=, First=Robert, Middle=S. Last=Mueller, Suffix=III")]
|
||||||
[DataRow("Frank T Vertosick Jr. MD", "Title=, First=Frank, Middle=T Last=Vertosick, Suffix=Jr. MD")]
|
[DataRow("Frank T Vertosick Jr. MD", "Title=, First=Frank, Middle=T Last=Vertosick, Suffix=Jr. MD")]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user