/** * gnome_xkb_info_get_layouts_for_country: * @self: a #GnomeXkbInfo * @country_code: an ISO 3166 code string * * Returns a list of all layout identifiers we know about for * @country_code. * * Return value: (transfer container) (element-type utf8): the list * of layout ids. The caller takes ownership of the #GList but not of * the strings themselves, those are internally allocated and must not * be modified. * * Since: 3.8 */ GList * gnome_xkb_info_get_layouts_for_country (GnomeXkbInfo *self, const gchar *country_code) { GnomeXkbInfoPrivate *priv; GHashTable *layouts_for_country; gchar *country; GList *list; g_return_val_if_fail (GNOME_IS_XKB_INFO (self), NULL); priv = self->priv; if (!ensure_rules_are_parsed (self)) return NULL; country = gnome_get_country_from_code (country_code, NULL); if (!country) return NULL; layouts_for_country = g_hash_table_lookup (priv->layouts_by_country, country); g_free (country); if (!layouts_for_country) return NULL; list = NULL; g_hash_table_foreach (layouts_for_country, collect_layout_ids, &list); return list; }
static char * translated_city_name (TzLocation *loc) { char *country; char *name; char *zone_translated; char **split_translated; gint length; /* Load the translation for it */ zone_translated = g_strdup (dgettext (GETTEXT_PACKAGE_TIMEZONES, loc->zone)); g_strdelimit (zone_translated, "_", ' '); split_translated = g_regex_split_simple ("[\\x{2044}\\x{2215}\\x{29f8}\\x{ff0f}/]", zone_translated, 0, 0); g_free (zone_translated); length = g_strv_length (split_translated); country = gnome_get_country_from_code (loc->country, NULL); /* Translators: "city, country" */ name = g_strdup_printf (C_("timezone loc", "%s, %s"), split_translated[length-1], country); g_free (country); g_strfreev (split_translated); return name; }
static void add_layout_to_locale_tables (Layout *layout, GHashTable *layouts_by_language, GHashTable *layouts_by_country) { GSList *l, *lang_codes, *country_codes; gchar *language, *country; lang_codes = layout->iso639Ids; country_codes = layout->iso3166Ids; if (layout->is_variant) { if (!lang_codes) lang_codes = layout->main_layout->iso639Ids; if (!country_codes) country_codes = layout->main_layout->iso3166Ids; } for (l = lang_codes; l; l = l->next) { language = gnome_get_language_from_code ((gchar *) l->data, NULL); if (language) { add_layout_to_table (layouts_by_language, language, layout); g_free (language); } } for (l = country_codes; l; l = l->next) { country = gnome_get_country_from_code ((gchar *) l->data, NULL); if (country) { add_layout_to_table (layouts_by_country, country, layout); g_free (country); } } }