Support alternative locale names in tests

This commit is contained in:
Victor Zverovich
2021-05-24 12:22:52 -07:00
parent 1f308a3cea
commit 883d9595c5
4 changed files with 37 additions and 9 deletions
+11 -2
View File
@@ -27,11 +27,20 @@ fmt::buffered_file open_buffered_file(FILE** fp) {
return f;
}
std::locale get_locale(const char* name) {
std::locale do_get_locale(const char* name) {
try {
return std::locale(name);
} catch (const std::runtime_error&) {
fmt::print(stderr, "{} locale is missing.\n", name);
}
return std::locale::classic();
}
std::locale get_locale(const char* name, const char* alt_name) {
auto loc = do_get_locale(name);
if (loc == std::locale::classic() && alt_name) {
loc = do_get_locale(alt_name);
}
if (loc == std::locale::classic())
fmt::print(stderr, "{} locale is missing.\n", name);
return loc;
}