Automatically Set User Language

Is there a way to determine what language the user has selected at a device level? Basically I want to set the locale progammatically on main init based on the language set on a OS level using journey.locale = {OS language}.

Have you tried using navigator.language or the first element in navigator.languages?