diff --git a/libmalcontent-ui/gs-content-rating.c b/libmalcontent-ui/gs-content-rating.c index e04ace8..e7b0eea 100644 --- a/libmalcontent-ui/gs-content-rating.c +++ b/libmalcontent-ui/gs-content-rating.c @@ -462,11 +462,31 @@ static const gchar *content_rating_strings[GS_CONTENT_RATING_SYSTEM_LAST][7] = { { "3+", "7+", "12+", "16+", "18+", NULL }, /* GS_CONTENT_RATING_SYSTEM_IARC */ }; -const gchar * const * +gchar ** gs_utils_content_rating_get_values (GsContentRatingSystem system) { - g_assert (system < GS_CONTENT_RATING_SYSTEM_LAST); - return content_rating_strings[system]; + g_return_val_if_fail ((int) system < GS_CONTENT_RATING_SYSTEM_LAST, NULL); + + /* IARC is the fallback for everything */ + if (system == GS_CONTENT_RATING_SYSTEM_UNKNOWN) + system = GS_CONTENT_RATING_SYSTEM_IARC; + + /* ESRB is special as it requires localised suffixes */ + if (system == GS_CONTENT_RATING_SYSTEM_ESRB) { + g_auto(GStrv) esrb_ages = g_new0 (gchar *, 7); + + esrb_ages[0] = get_esrb_string (content_rating_strings[system][0], _("Early Childhood")); + esrb_ages[1] = get_esrb_string (content_rating_strings[system][1], _("Everyone")); + esrb_ages[2] = get_esrb_string (content_rating_strings[system][2], _("Everyone 10+")); + esrb_ages[3] = get_esrb_string (content_rating_strings[system][3], _("Teen")); + esrb_ages[4] = get_esrb_string (content_rating_strings[system][4], _("Mature")); + esrb_ages[5] = get_esrb_string (content_rating_strings[system][5], _("Adults Only")); + esrb_ages[6] = NULL; + + return g_steal_pointer (&esrb_ages); + } + + return g_strdupv ((gchar **) content_rating_strings[system]); } static guint content_rating_ages[GS_CONTENT_RATING_SYSTEM_LAST][7] = { diff --git a/libmalcontent-ui/gs-content-rating.h b/libmalcontent-ui/gs-content-rating.h index 3051fd7..3b79460 100644 --- a/libmalcontent-ui/gs-content-rating.h +++ b/libmalcontent-ui/gs-content-rating.h @@ -51,7 +51,7 @@ gchar *gs_utils_content_rating_age_to_str (GsContentRatingSystem system, guint age); GsContentRatingSystem gs_utils_content_rating_system_from_locale (const gchar *locale); const gchar *gs_content_rating_system_to_str (GsContentRatingSystem system); -const gchar * const *gs_utils_content_rating_get_values (GsContentRatingSystem system); +gchar **gs_utils_content_rating_get_values (GsContentRatingSystem system); const guint *gs_utils_content_rating_get_ages (GsContentRatingSystem system); guint as_content_rating_id_value_to_csm_age (const gchar *id, MctAppFilterOarsValue value); MctAppFilterOarsValue as_content_rating_id_csm_age_to_value (const gchar *id, guint age); diff --git a/libmalcontent-ui/user-controls.c b/libmalcontent-ui/user-controls.c index ae0cf8a..e1baf7b 100644 --- a/libmalcontent-ui/user-controls.c +++ b/libmalcontent-ui/user-controls.c @@ -316,7 +316,7 @@ static void update_categories_from_language (MctUserControls *self) { GsContentRatingSystem rating_system; - const gchar * const * entries; + g_auto(GStrv) entries = NULL; const gchar *rating_system_str; const guint *ages; gsize i; @@ -680,7 +680,7 @@ on_set_age_action_activated (GSimpleAction *action, { GsContentRatingSystem rating_system; MctUserControls *self; - const gchar * const * entries; + g_auto(GStrv) entries = NULL; const guint *ages; guint age; guint i;