--- a/liblightdm-gobject/language.c
+++ b/liblightdm-gobject/language.c
@@ -210,6 +210,7 @@
 
     if (!priv->name)
     {
+#if HAVE_LC_IDENTIFICATION
         g_autofree gchar *locale = get_locale_name (priv->code);
         if (locale)
         {
@@ -224,6 +225,7 @@
             setlocale (LC_ALL, current);
         }
         if (!priv->name)
+#endif
         {
             g_auto(GStrv) tokens = g_strsplit_set (priv->code, "_.@", 2);
             priv->name = g_strdup (tokens[0]);
@@ -250,6 +252,7 @@
 
     if (!priv->territory && strchr (priv->code, '_'))
     {
+#if HAVE_LC_IDENTIFICATION
         g_autofree gchar *locale = get_locale_name (priv->code);
         if (locale)
         {
@@ -264,6 +267,7 @@
             setlocale (LC_ALL, current);
         }
         if (!priv->territory)
+#endif
         {
             g_auto(GStrv) tokens = g_strsplit_set (priv->code, "_.@", 3);
             priv->territory = g_strdup (tokens[1]);
