Extragalactic globular clusters. I, The metallicity calibration