To charge a battery, you need to apply some direct current (DC). The electricity that comes out of the wall is alternating current (AC) because AC travels better than DC. Therefore, to make a battery charger, you need to convert the AC to DC. Another problem is that the electricity that comes out of the wall is 120 volts and to charge a battery you need much less voltage. Fortunately, one of the key components of a device that changes AC to DC is a transformer -- a component that can change the voltage level.
Feed the current coming out of the wall into the primary winding of a transformer. You should choose a transformer that steps the voltage down to the level of the batteries you want to charge. If you are charging 6-volt batteries, the ratio of the windings in the primary side of the transformer will be 20 times as many as the windings on the secondary side because 120/6 = 20. So 120 volts AC comes in and 6 volts AC goes out.
Send the output from the transformer -- the secondary coil -- to two corners of a Wheatstone bridge. This is a diamond-shaped structure made by connecting four diodes so that when the inputs -- two corners of the diamond -- are presented with an alternating current, the positive parts of the cycle always go to one corner of the bridge and the negative parts of the cycle always go to another corner of the bridge. A Wheatstone bridge converts AC to DC, but is an unusual type of DC. Current always goes in the same direction, but it oscillates between zero and maximum at twice the rate that the AC oscillated.
Send the "rippling DC" through a filter. Filters consist of coils that oppose the change in current. Just before the coil is a capacitor across the circuit. As the current rises, the coil opposes the change and backs up some of the electrons onto the plates of the capacitor. When the current falls, these stored electrons discharge and add to the declining current. These two components work together to flatten out the surges and fill in the valleys of the rippling DC and make the current flow smoother.
For an inexpensive alternative, when the amount of ripple is not important, you can replace the coil with a cheaper resister. Resistors do not work as well in this application, but they do work and they are a lot cheaper.
The voltage output of a rectifier is fixed -- determined by the transformer. If you want to have several different voltages -- to charge several different types of batteries, you should put a series of resistors across the output of the rectifier. The resistors should be chosen so that tapping between the resistors gives the voltage levels you need.