Index: includes/install.core.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/install.core.inc,v
retrieving revision 1.48
diff -u -p -r1.48 install.core.inc
--- includes/install.core.inc	28 Dec 2010 18:17:27 -0000	1.48
+++ includes/install.core.inc	29 Dec 2010 18:38:23 -0000
@@ -1122,7 +1122,9 @@ function install_find_locales($profilena
   array_unshift($locales, (object) array('name' => 'en'));
   foreach ($locales as $key => $locale) {
     // The locale (file name) might be drupal-7.2.cs.po instead of cs.po.
-    $locales[$key]->langcode = preg_replace('!^(.+\.)?([^\.]+)$!', '\2', $locale->name);
+    // Language code cannot exceed 12 characters to fit into the {languages}
+    // table.
+    $locales[$key]->langcode = substr(preg_replace('!^(.+\.)?([^\.]+)$!', '\2', $locale->name), 0, 12);
   }
   return $locales;
 }
@@ -1370,8 +1372,17 @@ function install_profile_modules(&$insta
 function install_import_locales(&$install_state) {
   include_once DRUPAL_ROOT . '/includes/locale.inc';
   $install_locale = $install_state['parameters']['locale'];
-  // Enable installation language as default site language.
-  locale_add_language($install_locale, NULL, NULL, NULL, '', NULL, 1, TRUE);
+
+  include_once DRUPAL_ROOT . '/includes/iso.inc';
+  $predefined = _locale_get_predefined_list();
+  if (!isset($predefined[$install_locale])) {
+    locale_add_language($install_locale, $install_locale, $install_locale, LANGUAGE_LTR, '', '', TRUE, TRUE);
+  }
+  else {
+    // A known predefined language, details will be filled in properly.
+    locale_add_language($install_locale, NULL, NULL, NULL, '', '', TRUE, TRUE);
+  }
+
   // Collect files to import for this language.
   $batch = locale_batch_by_language($install_locale, NULL);
   if (!empty($batch)) {
Index: includes/install.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/install.inc,v
retrieving revision 1.151
diff -u -p -r1.151 install.inc
--- includes/install.inc	28 Dec 2010 18:17:27 -0000	1.151
+++ includes/install.inc	29 Dec 2010 19:09:56 -0000
@@ -1072,7 +1072,8 @@ function st($string, array $args = array
       // with its name ending in {$install_state['parameters']['locale']}.po
       // This might or might not be the entire filename. It is also possible
       // that multiple files end with the same extension, even if unlikely.
-      $po_files = file_scan_directory('./profiles/' . $install_state['parameters']['profile'] . '/translations', '/'. $install_state['parameters']['locale'] .'\.po$/', array('recurse' => FALSE));
+      $mask = '/' . $install_state['parameters']['locale'] . '[^\.]*\.po$/';
+      $po_files = file_scan_directory('./profiles/' . $install_state['parameters']['profile'] . '/translations', $mask, array('recurse' => FALSE));
       if (count($po_files)) {
         require_once DRUPAL_ROOT . '/includes/locale.inc';
         foreach ($po_files as $po_file) {
Index: includes/locale.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/locale.inc,v
retrieving revision 1.264
diff -u -p -r1.264 locale.inc
--- includes/locale.inc	21 Nov 2010 09:01:30 -0000	1.264
+++ includes/locale.inc	29 Dec 2010 19:23:53 -0000
@@ -1961,7 +1961,8 @@ function locale_batch_by_language($langc
     // with names ending with $langcode.po. This allows for filenames
     // like node-module.de.po to let translators use small files and
     // be able to import in smaller chunks.
-    $files = array_merge($files, file_scan_directory(dirname($component->filename) . '/translations', '/(^|\.)' . $langcode . '\.po$/', array('recurse' => FALSE)));
+    $mask = '/(^|\.)' . $langcode . '[^\.]*\.po$/';
+    $files = array_merge($files, file_scan_directory(dirname($component->filename) . '/translations', $mask, array('recurse' => FALSE)));
     $components[] = $component->name;
   }
 
@@ -2052,9 +2053,12 @@ function _locale_batch_build($files, $fi
 function _locale_batch_import($filepath, &$context) {
   // The filename is either {langcode}.po or {prefix}.{langcode}.po, so
   // we can extract the language code to use for the import from the end.
-  if (preg_match('!(/|\.)([^\./]+)\.po$!', $filepath, $langcode)) {
+  if (preg_match('!(/|\.)([^\./]+)\.po$!', $filepath, $matches)) {
+    // Language code cannot exceed 12 characters to fit into the {languages}
+    // table.
+    $langcode = substr($matches[2], 0, 12);
     $file = (object) array('filename' => basename($filepath), 'uri' => $filepath);
-    _locale_import_read_po('db-store', $file, LOCALE_IMPORT_KEEP, $langcode[2]);
+    _locale_import_read_po('db-store', $file, LOCALE_IMPORT_KEEP, $langcode);
     $context['results'][] = $filepath;
   }
 }
