British policy in South Africa was to encourage federation between the British-run Cape Colony and Colony of Natal , and the Boer republics , the South African Republic ( annexed by Britain in 1877 ) and the Orange Free State .