tests/languages.cpp: group the localization tests by locale

The original tests interleaved the locale being tested. This made
skipping tests if a locale was not available unreliable.

Restructuring the tests by locale also means that there is a single
place where the locale is changed, so there is only one skip message
displayed if the locale could not be loaded.