Internationally located extensions

Can anyone help me set up Asterisk to cope with extensions located internationally?

The problem is that someone in the UK dialing 0xxxx-xxxxxx will be wanting to dial a local UK number, while the same number dialed from a French extension will mean a number in Paris.

What I need is a way of parsing national (and if possible local) numbers based on blocks of source extension numbers. e.g. we assign 1000-1999 to UK numbers, 2000-2999 to France etc. and when an extension places a call of greater than 4 digits we add in the missing digits to bring the number up to the full E164 number that can then be routed with standard outgoing rules.

Has anyone had any experience with this? (Can’t believe I’m the first person to need this!!)