Commit 65e85214 authored by Jehan's avatar Jehan

plug-ins: better parse locales.

Be a little cleverer about what locale we care about in the context of
the help system. Variants and encoding in particular are of no interest
to us.
Let's also always add a base language (like "en" for "en_GB") rather
than fully trusting g_get_language_names() since it seems to return
funny results on some platform.
Finally check for duplicates before adding to language list.
parent 53465942
......@@ -127,6 +127,16 @@ gimp_help_parse_locales (const gchar *help_locales)
gchar *new = g_strndup (s, p - s);
gchar *c;
/* After a dot is displayed the optional encoding.
* We don't care in context of our help system.
*/
c = strchr (new, '.');
if (c)
*c = '\0';
/* We don't care about variants as well. */
c = strchr (new, '@');
if (c)
*c = '\0';
/* Apparently some systems (i.e. Windows) would return a value as
* IETF language tag, which is a different format from POSIX
* locale; especially it would separate the lang and the region
......@@ -141,8 +151,36 @@ gimp_help_parse_locales (const gchar *help_locales)
c = strchr (new, '-');
if (c)
*c = '_';
if (new && *new &&
! g_list_find_custom (locales, new,
(GCompareFunc) g_strcmp0))
{
gchar *base;
/* Adding this locale. */
locales = g_list_append (locales, new);
/* Adding the base language as well. */
base = strdup (new);
c = strchr (base, '_');
if (c)
*c = '\0';
if (base && *base &&
! g_list_find_custom (locales, base,
(GCompareFunc) g_strcmp0))
{
locales = g_list_append (locales, base);
}
else
{
g_free (base);
}
}
else
{
g_free (new);
}
locales = g_list_append (locales, new);
s = p + 1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment