no need for fallback to en-us, since language_code will always be set in this project template
rewrite language detection so getlocale() is first used. it will be set if someone explicitly used setlocale() in the current process, but is usually None. we then fall back to getdefaultlocale()
implement tests for language detection for: pt_BR => 'pt-br'; zh_HANS => 'zh-hans'; nonsensical foo_BA that should fall back to 'en-us' and special-looking locale 'udm'. also add a helper method to share some code with other tests.