Unverified Commit 670f1626 authored by alexpott's avatar alexpott

Issue #2413191 by claudiu.cristea, alexpott, andyceo, andypost, laszlo.kovacs,...

Issue #2413191 by claudiu.cristea, alexpott, andyceo, andypost, laszlo.kovacs, Dane Powell, Gábor Hojtsy, pfrenssen: Shipping a profile with multiple languages without locale module not possible

(cherry picked from commit d37aea09)
parent a5042ffc
......@@ -758,7 +758,8 @@ function install_tasks($install_state) {
// 'install_import_translations' task. Import when a non-English language is
// available and selected. Also we will need translations even if the
// installer language is English but there are other languages on the system.
$needs_translations = (count($install_state['translations']) > 1 && !empty($install_state['parameters']['langcode']) && $install_state['parameters']['langcode'] != 'en') || \Drupal::languageManager()->isMultilingual();
$locale_module_installed = \Drupal::moduleHandler()->moduleExists('locale');
$needs_translations = $locale_module_installed && ((count($install_state['translations']) > 1 && !empty($install_state['parameters']['langcode']) && $install_state['parameters']['langcode'] != 'en') || \Drupal::languageManager()->isMultilingual());
// Determine whether a translation file must be downloaded during the
// 'install_download_translation' task. Download when a non-English language
// is selected, but no translation is yet in the translations directory.
......
<?php
namespace Drupal\FunctionalTests\Installer;
use Drupal\Core\Serialization\Yaml;
/**
* Tests installing a profile with non-English language and no locale module.
*
* @group Installer
*/
class InstallerNonEnglishProfileWithoutLocaleModuleTest extends InstallerTestBase {
/**
* The testing profile name.
*
* @var string
*/
const PROFILE = 'testing_with_language_without_locale';
/**
* {@inheritdoc}
*/
protected $profile = self::PROFILE;
/**
* {@inheritdoc}
*/
protected function prepareEnvironment() {
parent::prepareEnvironment();
// Create a self::PROFILE testing profile that depends on the 'language'
// module but not on 'locale' module.
$profile_info = [
'type' => 'profile',
'core' => \Drupal::CORE_COMPATIBILITY,
'name' => 'Test with language but without locale',
'install' => ['language'],
];
// File API functions are not available yet.
$profile_dir = "{$this->root}/{$this->siteDirectory}/profiles/" . self::PROFILE;
$profile_config_dir = "$profile_dir/config/install";
mkdir($profile_config_dir, 0777, TRUE);
$profile_info_file = $profile_dir . '/' . static::PROFILE . '.info.yml';
file_put_contents($profile_info_file, Yaml::encode($profile_info));
// Copy a non-English language config YAML to be installed with the profile.
copy($this->root . '/core/profiles/testing_multilingual/config/install/language.entity.de.yml', $profile_config_dir . '/language.entity.de.yml');
}
/**
* Tests installing a profile with non-English language and no locale module.
*/
public function testNonEnglishProfileWithoutLocaleModule() {
$this->assertSession()->statusCodeEquals(200);
$this->assertUrl('user/1');
// Confirm that we are logged-in after installation.
$this->assertText($this->rootUser->getAccountName());
// Verify that the confirmation message appears.
require_once $this->root . '/core/includes/install.inc';
$this->assertRaw(t('Congratulations, you installed @drupal!', [
'@drupal' => drupal_install_profile_distribution_name(),
]));
$this->assertFalse(\Drupal::service('module_handler')->moduleExists('locale'), 'The Locale module is not installed.');
$this->assertTrue(\Drupal::service('module_handler')->moduleExists('language'), 'The Language module is installed.');
$this->assertTrue(\Drupal::languageManager()->isMultilingual(), 'The language manager is multi-lingual.');
}
}
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