diff --git a/core/includes/install.inc b/core/includes/install.inc
index ad911db..9e7731b 100644
--- a/core/includes/install.inc
+++ b/core/includes/install.inc
@@ -1046,15 +1046,14 @@ function install_profile_info($profile, $langcode = 'en') {
     $profile_file = drupal_get_path('profile', $profile) . "/$profile.info.yml";
     $info = \Drupal::service('info_parser')->parse($profile_file);
     $info += $defaults;
+    if ($langcode != 'en' && !empty($langcode) && !in_array('locale', $info['dependencies'])) {
+      $info['dependencies'][] = 'locale';
+    }
 
     // drupal_required_modules() includes the current profile as a dependency.
     // Remove that dependency, since a module cannot depend on itself.
     $required = array_diff(drupal_required_modules(), array($profile));
-
-    $locale = !empty($langcode) && $langcode != 'en' ? array('locale') : array();
-
-    $info['dependencies'] = array_unique(array_merge($required, $info['dependencies'], $locale));
-
+    $info['dependencies'] = array_unique(array_merge($required, module_order_by_dependencies($info['dependencies'])));
     $cache[$profile] = $info;
   }
   return $cache[$profile];
