Dogs are social beings and have minds. They understand cursing and thanking. Maybe not the actual words, but certainly the emotion behind them.