diff --git a/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp b/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp index 4e9828663f..da5235e491 100644 --- a/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp +++ b/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp @@ -71,10 +71,16 @@ void QComposeInputContext::ensureInitialized() } m_initialized = true; - const char *locale = setlocale(LC_CTYPE, ""); - if (!locale) - locale = setlocale(LC_CTYPE, nullptr); - qCDebug(lcXkbCompose) << "detected locale (LC_CTYPE):" << locale; + // Get locale from user env settings, see also + // https://xkbcommon.org/doc/current/group__compose.html#compose-locale + const char *locale = getenv("LC_ALL"); + if (!locale || !*locale) + locale = getenv("LC_CTYPE"); + if (!locale || !*locale) + locale = getenv("LANG"); + if (!locale || !*locale) + locale = "C"; + qCDebug(lcXkbCompose) << "detected locale:" << locale; m_composeTable = xkb_compose_table_new_from_locale(m_XkbContext, locale, XKB_COMPOSE_COMPILE_NO_FLAGS); if (m_composeTable)