Hyperfine spectra of trapped bosons in optical lattices