Commit 0350c459 authored by Florent Revest's avatar Florent Revest

mlite: Allow dynamic locale switch in MDesktopEntry

parent ee4e8b9f
From 0ec6c5c9751557907a93ee755ba1e5a891352dc5 Mon Sep 17 00:00:00 2001
From: Florent Revest <revestflo@gmail.com>
Date: Thu, 30 Nov 2017 22:02:48 +0100
Subject: [PATCH] MDesktopEntry: Allow dynamic locale switch by disabling some
of the asumptions made when using glib's conf files functions
---
src/mdesktopentry.cpp | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/src/mdesktopentry.cpp b/src/mdesktopentry.cpp
index cca6af0..628eaab 100644
--- a/src/mdesktopentry.cpp
+++ b/src/mdesktopentry.cpp
@@ -66,7 +66,7 @@ bool GKeyFileWrapper::load(QIODevice &device)
QByteArray contents = device.readAll();
GError *err = NULL;
- if (!g_key_file_load_from_data(m_key_file, contents.constData(), contents.size(), G_KEY_FILE_NONE, &err)) {
+ if (!g_key_file_load_from_data(m_key_file, contents.constData(), contents.size(), G_KEY_FILE_KEEP_TRANSLATIONS, &err)) {
qWarning() << "Could not load .desktop file:" << QString::fromUtf8(err->message);
g_clear_error(&err);
return false;
@@ -129,9 +129,10 @@ QString GKeyFileWrapper::localizedValue(const QString &section, const QString &k
QByteArray section_utf8 = section.toUtf8();
QByteArray key_utf8 = key.toUtf8();
+ QByteArray locale_utf8 = QLocale().bcp47Name().toUtf8();
GError *err = NULL;
- gchar *value = g_key_file_get_locale_string(m_key_file, section_utf8.constData(), key_utf8.constData(), NULL, &err);
+ gchar *value = g_key_file_get_locale_string(m_key_file, section_utf8.constData(), key_utf8.constData(), locale_utf8.constData(), &err);
if (!value) {
qWarning() << "Could not read value:" << QString::fromUtf8(err->message);
g_clear_error(&err);
@@ -408,9 +409,6 @@ QString MDesktopEntry::name() const
{
Q_D(const MDesktopEntry);
- if (!d->translatedName.isNull())
- return d->translatedName;
-
QString name;
if (contains(DesktopEntrySection, LogicalIdKey)) {
@@ -432,7 +430,6 @@ QString MDesktopEntry::name() const
name = d->keyFile.localizedValue(DesktopEntrySection, NameKey);
}
- d->translatedName = name;
return name;
}
--
2.14.3
......@@ -3,7 +3,8 @@ HOMEPAGE = "https://git.merproject.org/mer-core/mlite"
LICENSE = "LGPL-2.1+"
LIC_FILES_CHKSUM = "file://src/mnotification.cpp;beginline=1;endline=18;md5=5dd5d73b0225b3099a82e6ad93283ea1"
SRC_URI = "git://git.merproject.org/mer-core/mlite.git;protocol=https"
SRC_URI = "git://git.merproject.org/mer-core/mlite.git;protocol=https \
file://0001-MDesktopEntry-Allow-dynamic-locale-switch-by-disabli.patch"
SRCREV = "144086d5f6c83abc721c8de503a83d4d1bb26fde"
PR = "r1"
PV = "+git${SRCPV}"
......
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