Commit 884ef73e authored by Guillaume Roguez's avatar Guillaume Roguez

i18n: loads language code only and full locale name for lrc

Qt loads only one specific file with QTranslate.load().
So if for example locale name is 'fr_CA', only this specific
translation will be loaded, but not 'fr', that may contains
usefull generic translations not given by lang_country one.

This patch fixes that by loading language code only fist
then 'language_COUNTRY' one.

Note: this is only for LRC translation. Gnome uses gettext.

Change-Id: I116b649bdf0ca9f26a9b68e0bb09cae8d48788c0
Reviewed-by: default avatarAnthony Léonard <>
parent bf695b43
......@@ -104,7 +104,8 @@ struct _RingClientPrivate {
/* UAM */
QMetaObject::Connection uam_updated;
std::unique_ptr<QTranslator> translator;
std::unique_ptr<QTranslator> translator_lang;
std::unique_ptr<QTranslator> translator_full;
GCancellable *cancellable;
......@@ -596,13 +597,27 @@ ring_client_startup(GApplication *app)
/* load translations from LRC */
priv->translator.reset(new QTranslator);
if (priv->translator->load(QLocale::system(), "lrc", "_", RING_CLIENT_INSTALL "/share/libringclient/translations")) {
} else {
const auto locale_name = QLocale::system().name();
const auto locale_lang = locale_name.split('_')[0];
if (locale_name != locale_lang) {
/* Install language first to have lowest priority */
priv->translator_lang.reset(new QTranslator);
if (priv->translator_lang->load(RING_CLIENT_INSTALL "/share/libringclient/translations/lrc_" + locale_lang)) {
g_debug("installed translations for %s", locale_lang.toUtf8().constData());
priv->translator_full.reset(new QTranslator);
if (priv->translator_full->load(RING_CLIENT_INSTALL "/share/libringclient/translations/lrc_" + locale_name)) {
g_debug("installed translations for %s", locale_name.toUtf8().constData());
if (not priv->translator_lang and not priv->translator_full) {
g_debug("could not load LRC translations for %s, %s",
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment