Skip to content
Snippets Groups Projects
Commit e0fad775 authored by Adam G-H's avatar Adam G-H
Browse files

Issue #3529159 by phenaproxima, anjali rathod, jose reyero: Bring the...

Issue #3529159 by phenaproxima, anjali rathod, jose reyero: Bring the installer's language selector back
parent 491b25ff
No related branches found
No related tags found
1 merge request!557Restore language selector but make it inert
Pipeline #518495 failed
......@@ -34,7 +34,7 @@ function drupal_cms_installer_install_tasks_alter(array &$tasks, array $install_
$langcode = $GLOBALS['install_state']['parameters']['langcode'];
$settings = Settings::getAll();
// @see install_profile_modules()
$settings["locale_custom_strings_$langcode"]['']['Installing @drupal'] = 'Setting up your site';
$settings["locale_custom_strings_$langcode"]['']['Installing @drupal'] = (string) t('Setting up your site');
new Settings($settings);
}
......
......@@ -245,3 +245,9 @@ body.install-page {
height: 100%;
}
}
.cms-installer__language-switcher {
position: absolute;
right: 0;
top: 0;
}
......@@ -5,7 +5,10 @@ maintenance-page:
css/fonts.css: {}
css/installer-styles.css: {}
css/add-ons.css: {}
js:
js/language-switcher.js: {}
dependencies:
- core/drupal
- core/once
drupal.progress:
......
......@@ -3,6 +3,7 @@
declare(strict_types=1);
use Drupal\Core\File\FileUrlGeneratorInterface;
use Drupal\Core\Language\LanguageManager;
/**
* Implements template_preprocess_install_page().
......@@ -11,6 +12,12 @@ function drupal_cms_installer_theme_preprocess_install_page(array &$variables):
$theme_path = \Drupal::theme()->getActiveTheme()->getPath();
$variables['theme_path'] = \Drupal::service(FileUrlGeneratorInterface::class)
->generateString($theme_path);
$variables['languages'] = [];
foreach (LanguageManager::getStandardLanguageList() as $langcode => [$name]) {
$variables['languages'][$langcode] = $name;
}
asort($variables['languages']);
}
/**
......
(function (Drupal, once) {
"use strict";
/**
* Handles switching the selected language during installation.
*/
Drupal.behaviors.languageSwitcher = {
attach: function (context) {
once('language-switcher', 'select[name="langcode"]', context).forEach((el) => {
const url = new URL(window.location.href);
// Ensure the selected language is chosen.
el.value = url.searchParams.get('langcode') ?? 'en';
// Whenever the language is changed, redirect to the same page with the
// newly selected language code in the URL.
el.addEventListener('change', (event) => {
url.searchParams.set('langcode', event.target.value);
window.location.href = url.toString();
});
});
},
};
})(Drupal, once);
......@@ -18,6 +18,13 @@
<div class="cms-installer__wrapper">
<main class="cms-installer__main">
<select name="langcode" class="cms-installer__language-switcher">
{% for langcode, name in languages %}
<option value="{{ langcode }}">{{ name }}</option>
{% endfor %}
</select>
{% if title %}
<h2 class="cms-installer__main-heading">{{ title }}</h2>
{% endif %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment