refactored getLocalizedURL function