The tiny Pacific island nation of Nauru has legalized homosexuality, replacing its century-old criminal code with a new law that also criminalizes slavery and broadens the definition of rape to apply to married and unmarried couples.