Python BCP 47 parser extracted and modified from the Google Transit project