first working implementation of locale parsing