In The Rising Sea, Vakil says that $A = \mathbb{Z}[\sqrt{-5}]$ shows that the property "being the spectrum of a UFD" is not an affine-local property. Concretely, he points out that $D(2) = \operatorname{Spec} \mathbb{Z}[\sqrt{-5}]_2$ and $D(3)$ cover $\operatorname{Spec} A$, but claims that $\mathbb{Z}[\sqrt{-5}]_2$ and $\mathbb{Z}[\sqrt{-5}]_3$ are UFDs.
He sketches this second fact.
Show the class group of $\mathbb{Z}[\sqrt{-5}]$ is $\mathbb{Z}/2$ . . . Then show that the ideals $(1 + \sqrt{-5}, 2)$ and $(1 + \sqrt{-5}, 3)$ are not principal, using the usual norm.
I understand proofs of both of both facts he says here, and understand that these not-principal ideals become principal when we localize. Why does this then imply that the localization is a PID? That is, why does ideal class group $\mathbb{Z}/2$ imply that an arbitrary ideal is principal just because this particular ideal becomes principal in the localization?
Is there some general classification of what happens to the class group when we localize, say, at an integer?