There are a number of ways to combat "funky" category names generated from templates; unfortunately, many templates are not designed with any type of error checking system to help combat this.
In this case, I think I can offer a fairly simple solution:
Add in a parser function to test if the category name that will be added to the profile currently exists:
- If the category that will be generated for the profile already exists, the sticker and category are added to the profile normally.
- If the category does not yet exist, such as those misnamed categories, the sticker is added to the profile but the category output is suppressed.
As an example, the following template usage is properly formatted (and category named correctly) so will display the sticker and output a category of [[Category:6th Regiment, New York Cavalry, United States Civil War]] to the profile:
{{US Civil War
|side = USA
|enlisted = Sep 14, 1861
|mustered =Jun 30, 1865
|regiment flag = Civil_War_Flags-6.png
|regiment name = New York 6th Volunteer Cavalry
|rank=Corporal
|unit=6th Regiment, New York Cavalry
}}
On the other hand, the following template has an improperly named category, and only the sticker would be added to the profile (with no category!):
{{US Civil War
|side = USA
|enlisted = Sep 14, 1861
|mustered =Jun 30, 1865
|regiment flag = Civil_War_Flags-6.png
|regiment name = New York 6th Volunteer Cavalry
|rank=Corporal
|unit=6th Regiment
}}