change locale check, it should work on both Linux and FreeBSD now