[sound-juicer] Add MusicBrainz specific country codes
- From: Phillip Wood <pwood src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sound-juicer] Add MusicBrainz specific country codes
- Date: Wed, 9 Apr 2014 12:17:10 +0000 (UTC)
commit 6df6b3740dd359c624cdaf6eedc06eb7c4d692d7
Author: Phillip Wood <phillip wood dunelm org uk>
Date: Wed Apr 9 09:59:51 2014 +0100
Add MusicBrainz specific country codes
Musicbrainz uses some additional codes on top of ISO-3166 which were
not handled by commit d2d8da5 - Get country name ISO code. Treat these
extra codes as a special case if we don't get a match from the
iso-codes data.
https://bugzilla.gnome.org/show_bug.cgi?id=727813
libjuicer/sj-metadata.c | 27 +++++++++++++++++++++++++--
1 files changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/libjuicer/sj-metadata.c b/libjuicer/sj-metadata.c
index a24df0e..d02f7fe 100644
--- a/libjuicer/sj-metadata.c
+++ b/libjuicer/sj-metadata.c
@@ -334,7 +334,22 @@ char *
sj_metadata_helper_lookup_country_code (const char *code)
{
const char *country_name;
- int len;
+ int len, i;
+ /* Musicbrainz uses some additional codes on top of ISO-3166 so
+ treat those as a special case if we don't get a match from the
+ iso-codes data */
+ const static struct {
+ char *code;
+ char *name;
+ } mb_countries[] = {
+ {"XC", N_("Czechoslovakia")},
+ {"XG", N_("East Germany")},
+ {"XE", N_("Europe")},
+ {"CS", N_("Serbia and Montenegro")},
+ {"SU", N_("Soviet Union")},
+ {"XW", N_("Worldwide")},
+ {"YU", N_("Yugoslavia")}
+ };
g_return_val_if_fail (code != NULL, NULL);
@@ -349,6 +364,14 @@ sj_metadata_helper_lookup_country_code (const char *code)
if (country_name)
return g_strdup (dgettext ("iso_3166", country_name));
- g_warning ("Unknown country code: %s", code);
+ for (i = 0; i < G_N_ELEMENTS (mb_countries); i++) {
+ if (strcmp (code, mb_countries[i].code) == 0)
+ return g_strdup (gettext (mb_countries[i].name));
+ }
+
+ /* Musicbrainz uses XU for unknown so don't print an error, just
+ treat it as if a country wasn't provided */
+ if (strcmp (code, "XU") != 0)
+ g_warning ("Unknown country code: %s", code);
return NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]