"The man walks with his dog."
Translation:Siúlann an fear lena mhadra.
You can't. It's entirely down to context! With letters that don't mutate at all you can't distinguish 'he' from 'she' either - lena leabhar for example.
It's not as hard to deal with as you might think - think of how English does just fine without distinguishing you (sing.) and you (plur.). Somewhat tangentially, Lithuanian doesn't distinguish 'he works', 'she works' and 'they work', and that works out fine for them too.
Even the mutations can lead to ambiguities sometimes: a bhás (his death) sounds the same as a bhfás (their growth)!
Siúlann an fear lena mhadra - "The man walks with his dog"
Siúlann an bhean lena madra - "The woman walks with her dog"
Siúlann an fear leis - "The man walks with him/it"
Siúlann an fear le madra - "The man walks with a dog"
Siúlann an fear leis an madra - "The man walks with the dog"