Localization-induced optical properties of monolayer transition-metal dichalcogenides