Also, the city doesn't have to be originally settled by you. It works for AI cities (not City states) that you gain control over.
For example, I had a game where another AI city on another continent flipped to me due to tourism pressure. I got the bonus luxuries for the city that flipped.