The only way I can think to do this seems a bit complex so maybe there's ane asier way.
In Spanish (including modern day) often times the word "de" when set in all capitals is ligatured. However, a standard ligature isn't enough because de appears in many words. So I was going to do a contextual substitution to make sure I only nab DE as a single word.
BUT, this is of course unacceptable in most other languages. So here's my solution, and just wondering if I'm approaching it properly or if there is a more efficient way. (I'm using FontForge so I'll use psuedo code)
1: If language is "es", switch "D" with "D.es"
2: If language is "es", switch "E" with "E.es"
3: If sequence "[any letter] D.es E.es" found, match and do nothing
4: If sequence "D.es E.es [any letter]" found, match do nothing
5: If sequence "D.es E.es" found, replace with D_E
This requires making an extra glyph that is identical to a normal D and that in a Spanish document would be constantly being replaced. I'm not sure if that in and of itself might cause concern as well.