Properly handle locales with country codes

Fixes #2890.
Yessssssss. Glad to see this global cwd dependency disappear.