Undubbing is usually nothing more than rebuilding the US or EU release with the Japanese audio (rearrange regions as desired).
Unpack Japanese (donor) rom and find audio (usually has extension sdat)
Unpack US or EU rom and find audio (probably in the same directory as the Japanese or with a given subdirectory)
Replace US or EU audio with Japanese audio.
There are many many tools able to parse and edit the DS file system and for this sort of thing you can even do it manually as I will detail in passing.
ndstool which has frontends in DSlazy and DSBuff are the most common but they are not brilliant and fail to work properly for some roms.
I have the basics here:
crystaltile2, ndsts and ndshv.
One step short of going manual and assuming you have a same size file or smaller file you pad with 00s then you can overwrite the file in rom and touch nothing else (one of the main reasons ndstool fails)
Manual works like above but can be used when you have bigger files, you need to understand how the DS file system works http://nocash.emubase.de/gbatek.htm#dscart...roromfilesystem
If something more is required we have to start delving into sound hacking proper, the general idea is you make a file that matches the base rom you are using (If the Japanese sound file has sounds in a different order or more sounds you have to make the US game think the sound file is as it expects, threads/pages that might interest you for this)
Most of the time though it is just ndstool being less than brilliant for commercial rom rebuilding (it is just a homebrew tool repurposed by the rom hacking community) if a rom fails for the basic undub though.