[recipes] Add an api to get untranslated ingredients names
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Add an api to get untranslated ingredients names
- Date: Sun, 1 Jan 2017 16:06:16 +0000 (UTC)
commit 5e298e411024d51735a93076189cb051c5c08764
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Dec 31 15:49:29 2016 -0500
Add an api to get untranslated ingredients names
We slowly work our way toward proper ingredient objects.
src/gr-ingredient.c | 19 +++++++++++++++++++
src/gr-ingredient.h | 1 +
2 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/src/gr-ingredient.c b/src/gr-ingredient.c
index b8c3d5a..b55bd15 100644
--- a/src/gr-ingredient.c
+++ b/src/gr-ingredient.c
@@ -91,6 +91,25 @@ gr_ingredient_find (const char *text)
}
const char *
+gr_ingredient_get_id (const char *name)
+{
+ int i;
+ g_autofree char *cf_text = NULL;
+
+ translate_names ();
+
+ cf_text = g_utf8_casefold (name, -1);
+
+ for (i = 0; names[i]; i++) {
+ if (strcmp (cf_text, cf_names[i]) == 0 ||
+ strcmp (cf_text, cf_en_names[i]) == 0)
+ return names_[i];
+ }
+
+ return NULL;
+}
+
+const char *
gr_ingredient_get_negation (const char *name)
{
int i;
diff --git a/src/gr-ingredient.h b/src/gr-ingredient.h
index c834fb4..a36dad2 100644
--- a/src/gr-ingredient.h
+++ b/src/gr-ingredient.h
@@ -26,6 +26,7 @@ G_BEGIN_DECLS
const char **gr_ingredient_get_names (int *length);
const char *gr_ingredient_find (const char *text);
+const char *gr_ingredient_get_id (const char *name);
const char *gr_ingredient_get_negation (const char *name);
char *gr_ingredient_get_image (const char *name);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]