Fix exception when locale isn't set

Method was throwing an exception if locale wasn't set.
Set a default if empty. Also cleanup method a bit.