[gnome-software/wip/rancell/reviews] Correctly set review language
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/rancell/reviews] Correctly set review language
- Date: Thu, 11 Feb 2016 02:41:24 +0000 (UTC)
commit a5f42e6200621d1817b45b0735269ffb8a5ad6cd
Author: Robert Ancell <robert ancell canonical com>
Date: Thu Feb 11 15:41:15 2016 +1300
Correctly set review language
src/plugins/gs-plugin-ubuntu-reviews.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/src/plugins/gs-plugin-ubuntu-reviews.c b/src/plugins/gs-plugin-ubuntu-reviews.c
index e41b110..1f3f67c 100644
--- a/src/plugins/gs-plugin-ubuntu-reviews.c
+++ b/src/plugins/gs-plugin-ubuntu-reviews.c
@@ -21,6 +21,7 @@
#include <config.h>
+#include <string.h>
#include <math.h>
#include <libsoup/soup.h>
#include <json-glib/json-glib.h>
@@ -751,7 +752,8 @@ set_package_review (GsPlugin *plugin,
GsPluginPrivate *priv = plugin->priv;
gint rating;
gint n_stars;
- g_autofree gchar *uri = NULL, *os_id = NULL, *os_ubuntu_codename = NULL;
+ g_autofree gchar *uri = NULL, *os_id = NULL, *os_ubuntu_codename = NULL, *language = NULL;
+ gchar *c;
g_autoptr(SoupMessage) msg;
JsonBuilder *builder;
guint status_code;
@@ -776,6 +778,12 @@ set_package_review (GsPlugin *plugin,
if (os_ubuntu_codename == NULL)
return FALSE;
+ /* Convert locale into language */
+ language = g_strdup (plugin->locale);
+ c = strchr (language, '_');
+ if (c)
+ *c = '\0';
+
/* Create message for reviews.ubuntu.com */
uri = g_strdup_printf ("%s/api/1.0/reviews/", UBUNTU_REVIEWS_SERVER);
msg = soup_message_new (SOUP_METHOD_POST, uri);
@@ -784,7 +792,7 @@ set_package_review (GsPlugin *plugin,
add_string_member (builder, "package_name", package_name);
add_string_member (builder, "summary", gs_review_get_summary (review));
add_string_member (builder, "review_text", gs_review_get_text (review));
- add_string_member (builder, "language", "en"); // FIXME
+ add_string_member (builder, "language", language);
add_string_member (builder, "origin", os_id);
add_string_member (builder, "distroseries", os_ubuntu_codename);
add_string_member (builder, "version", gs_review_get_version (review));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]