What does the quote from the Old Testament in Luke 2: 23 refer to? We read at Luke 2: 22-23:


  When the time came for their purification according to the law of Moses, they brought him up to Jerusalem to present him to the Lord   (as it is written in the law of the Lord, “Every firstborn male shall be designated as holy to the Lord”) .


Though the cross-references cited in RSVCE are Leviticus 12: 2-8 and Exodus 13: 2&amp; 12, the said references mention purification after the birth of both sons and daughters. It is not clear how and when the exclusiveness of the male child took shape. Insertion of the quote from the OT in parentheses also calls for some elucidation.

My question is: was the narrative of Luke, specifically the reference to the OT, on the dedication of Jesus at the Temple, based on tradition rather than on the exact texts of the OT? What do the teachings of the Catholic Church tell about such a prospect?
The RSV (and KJV and Septuagint) goes on from the general statement of all first-born at Ex. 13:2 to the specific male first-born at 13:12, 13 and elsewhere.  So, the dedication of Jesus at the Temple in Luke 2:23 is based on Scripture.

&quot;Consecrate to me all the first-born; whatever is the first to open the womb among the people of Israel, both of man and of beast, is mine.&quot; Ex. 13:2
you shall set apart to the LORD all that first opens the womb. All the firstlings of your cattle that are males shall be the LORD's. Ex. 13:12
Every firstling of an ass you shall redeem with a lamb, or if you will not redeem it you shall break its neck. Every first-born of man among your sons you shall redeem. Ex. 13:13

Moreover, the Septuagint confirms this quote.

(as it is written in the law of the Lord, &quot;Every male that opens the womb shall be called holy to the Lord&quot;) Luke 2:23
The first-born of thy sons thou shalt give to me. Ex. 22:29 Septuagint
that thou shalt set apart every [offspring] opening the womb, the males to the Lord, every one that opens the womb out of the herds or among thy cattle, as many as thou shalt have: thou shalt sanctify the males to the Lord. Ex. 13:12