In Portuguese, when we use a verb that asks for both a direct and indirect object (and they’re pointed out specifically — i.e. we’re aware of what/who they are), we can contract these two pronouns by adding the third person direct pronouns to the indirect object pronoun. Sounds complicated, we know. Let’s see a practical example:
Dei uma prenda à Joana. I gave Joana a gift.
In this sentence, neither the direct object (uma prenda) nor the indirect object (à Joana) have been replaced by a clitic.
Dei-lhe uma prenda. I gave her a gift.
In this sentence, the indirect object (à Joana) has been replaced by the clitic –lhe, while the direct object remains in place.
Dei-lha. I gave it to her.
Finally, both objects have been replaced by clitics – “a prenda” was replaced by the clitic –a and “à Joana” was replaced by the clitic -lhe. Then, the two were merged: -lhe + -a = -lha.
This merger only works when the direct object is in the third person. If the direct object is in the first or second persons, it’s not possible to merge the two.
The table below shows how to make these mergers between indirect object pronouns (me, te, lhe, nos, vos) and 3rd person direct object pronouns (o, a, os, as).
These mergers are not usually done with –lhes. When -lhes is replacing your indirect object, we maintain the direct object in place after it.
Nós demos-lhes um computador. We gave them a computer.