[gnome-software] Add a kudo if an application is available in the users language
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Add a kudo if an application is available in the users language
- Date: Wed, 26 Feb 2014 21:30:59 +0000 (UTC)
commit cb25a4462d2db045e273c90b33389a9560d6b004
Author: Richard Hughes <richard hughsie com>
Date: Wed Feb 26 21:18:58 2014 +0000
Add a kudo if an application is available in the users language
src/plugins/gs-plugin-appstream.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index 27f708a..72caef7 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -33,6 +33,7 @@
struct GsPluginPrivate {
AppstreamCache *cache;
GPtrArray *file_monitors;
+ gchar *locale;
gchar *cachedir;
gsize done_init;
};
@@ -305,6 +306,7 @@ void
gs_plugin_destroy (GsPlugin *plugin)
{
g_free (plugin->priv->cachedir);
+ g_free (plugin->priv->locale);
g_object_unref (plugin->priv->cache);
g_ptr_array_unref (plugin->priv->file_monitors);
}
@@ -318,8 +320,15 @@ gs_plugin_startup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
AppstreamApp *app;
GPtrArray *items;
gboolean ret;
+ gchar *tmp;
guint i;
+ /* get the locale without the UTF-8 suffix */
+ plugin->priv->locale = g_strdup (setlocale (LC_MESSAGES, NULL));
+ tmp = g_strstr_len (plugin->priv->locale, -1, ".UTF-8");
+ if (tmp != NULL)
+ *tmp = '\0';
+
/* clear all existing file monitors */
g_ptr_array_set_size (plugin->priv->file_monitors, 0);
@@ -610,6 +619,11 @@ gs_plugin_refine_item (GsPlugin *plugin,
/* set screenshots */
gs_plugin_refine_add_screenshots (app, item);
+ /* is available in my language */
+ g_debug ("looking for %s", plugin->priv->locale);
+ if (appstream_app_has_locale (item, plugin->priv->locale) > 50)
+ gs_app_add_kudo (app, GS_APP_KUDO_MY_LANGUAGE);
+
return ret;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]