  We present the theoretical framework and numerical methods we have
implemented to solve the problem of the generation and transfer of polarized
radiation in spectral lines out of local thermodynamical equilibrium, while
accounting for scattering polarization, partial frequency redistribution,
J-state interference, and hyperfine structure. The resulting radiative transfer
code allows modeling the impact of magnetic fields of arbitrary strength and
orientation through the Hanle, incomplete Paschen-Back, and magneto-optical
effects. We also evaluate the suitability of a series of approximations for
modeling the scattering polarization in the wings of strong resonance lines
that would be particularly useful for the numerically intensive case of
three-dimensional radiative transfer. We examine the suitability of the
considered approximation using our radiative transfer code to model the Stokes
profiles of the Mg II h & k lines and of the H I Lyman alpha line in magnetized
one-dimensional models of the solar atmosphere. Neglecting Doppler
redistribution in the scattering processes that are unperturbed by elastic
collisions produces a negligible error in the scattering polarization wings of
the Mg II resonance lines and a minor one in the Lyman alpha wings, although it
is unsuitable to model the cores of these lines. For both lines, the scattering
processes that are perturbed by elastic collisions give a significant
contribution only to the intensity component of the emissivity. Neglecting
collisional as well as Doppler redistribution represents a rough but suitable
approximation for the wings of the Mg II resonance lines, but a very poor one
for the Lyman alpha wings. The magnetic sensitivity in the scattering
polarization wings of the considered lines can be modeled by accounting for the
magnetic field only in the eta I and rho V coefficients of the Stokes-vector
transfer equation.
