mirror of
https://github.com/hyprwm/hyprutils.git
synced 2025-12-21 08:40:03 +01:00
e
This commit is contained in:
parent
c4757e57e5
commit
3844a10293
2 changed files with 7 additions and 6 deletions
|
|
@ -106,7 +106,9 @@ std::string CI18nEngine::localizeEntry(const std::string& locale, uint64_t key,
|
||||||
}
|
}
|
||||||
|
|
||||||
CI18nLocale CI18nEngine::getSystemLocale() {
|
CI18nLocale CI18nEngine::getSystemLocale() {
|
||||||
|
try {
|
||||||
return CI18nLocale(std::locale("").name());
|
return CI18nLocale(std::locale("").name());
|
||||||
|
} catch (...) { return CI18nLocale("en_US.UTF-8"); }
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HU_UNIT_TESTS
|
#ifdef HU_UNIT_TESTS
|
||||||
|
|
|
||||||
|
|
@ -49,13 +49,12 @@ std::string CI18nLocale::full() {
|
||||||
#include <hyprutils/i18n/I18nEngine.hpp>
|
#include <hyprutils/i18n/I18nEngine.hpp>
|
||||||
|
|
||||||
TEST(I18n, Locale) {
|
TEST(I18n, Locale) {
|
||||||
setenv("LANG", "pl_PL.UTF-8", true);
|
|
||||||
setenv("LC_CTYPE", "pl_PL.UTF-8", true);
|
|
||||||
|
|
||||||
CI18nEngine engine;
|
CI18nEngine engine;
|
||||||
|
|
||||||
EXPECT_EQ(engine.getSystemLocale().locale(), "pl_PL");
|
EXPECT_EQ(extractLocale("pl_PL.UTF-8"), "pl_PL");
|
||||||
EXPECT_EQ(engine.getSystemLocale().stem(), "pl");
|
EXPECT_EQ(extractLocale("POSIX"), "en_US");
|
||||||
|
EXPECT_EQ(extractLocale("*"), "en_US");
|
||||||
|
EXPECT_EQ(extractLocale("LC_CTYPE=pl_PL.UTF-8"), "pl_PL");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue