I made a map that should have what you wanted. It's very simple to use.
All you have to do is copy and paste the "Train Units" folder into your map. Then configure the "Setup Train Units" trigger, adding variables for each Unit Type that you plan on using with the system. There's more instructions inside of the triggers.
This uses the latest patch and Bribe's Unit Indexer.
Edit: Added Food Costs. For example, training a batch of Footman costs 4 Food but once created each individual Footman will only cost 1 Food.