You can probably use geonames for this. See, for example, Barcelona:
It shows "preferred" names for the languages Catalan and Spanish
and you'll notice that Madrid doesn't have Catalan as a preferred language
examples of export data: https://download.geonames.org/export/dump/readme.txt
so you'd need ...