  We study the density of group languages (i.e. rational languages recognized
by morphisms onto finite groups) inside shift spaces. The density of a rational
language can be understood as the frequency of some "pattern" in the shift
space, for example a pattern like "words with an even number of a given
letter." In this paper, we handle density of group languages via ergodicity of
skew products between the shift space and the recognizing group. We consider
both the cases of shifts of finite type (with a suitable notion of
irreducibility), and of minimal shifts. In the latter case, our main result is
a closed formula for the density which holds whenever the skew product has
minimal closed invariant subsets which are ergodic under the product of the
original measure and the uniform probability measure on the group. The formula
is derived in part from a characterization of minimal closed invariant subsets
for skew products relying on notions of cocycles and coboundaries. In the case
where the whole skew product itself is ergodic under the product measure, then
the density is completely determined by the cardinality of the image of the
language inside the recognizing group. We provide sufficient conditions for the
skew product to have minimal closed invariant subsets that are ergodic under
the product measure. Finally, we investigate the link between minimal closed
invariant subsets, return words and bifix codes.
