Catalonia has voted to declare itself an independent republic, and thousands of Catalans were celebrating in the streets.