added more robust language and locale checking