-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5.3] Minimize language selector in installation process #44735
base: 5.3-dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,24 +16,13 @@ | |
HTMLHelper::_('behavior.formvalidator'); | ||
|
||
/** @var \Joomla\CMS\Installation\View\Setup\HtmlView $this */ | ||
|
||
$wa = $this->getDocument()->getWebAssetManager(); | ||
|
||
$wa->useScript('joomla.dialog-autocreate'); | ||
?> | ||
|
||
<div id="installer-view" data-page-name="setup"> | ||
<form action="index.php" method="post" id="languageForm" class="lang-select"> | ||
<fieldset class="j-install-step active"> | ||
<legend class="j-install-step-header"> | ||
<span class="icon-language" aria-hidden="true"></span> <?php echo Text::_('INSTL_SELECT_INSTALL_LANG'); ?> | ||
</legend> | ||
<div class="j-install-step-form"> | ||
<div class="mb-3"> | ||
<?php echo $this->form->renderField('language'); ?> | ||
</div> | ||
<input type="hidden" name="task" value="language.set"> | ||
<input type="hidden" name="format" value="json"> | ||
<?php echo HTMLHelper::_('form.token'); ?> | ||
</div> | ||
</fieldset> | ||
</form> | ||
<form action="index.php" method="post" id="adminForm" class="form-validate"> | ||
<fieldset id="installStep1" class="j-install-step active"> | ||
<legend class="j-install-step-header"> | ||
|
@@ -134,5 +123,26 @@ | |
<input type="hidden" name="admin_password2" id="jform_admin_password2"> | ||
<?php echo HTMLHelper::_('form.token'); ?> | ||
</form> | ||
<form action="index.php" method="post" id="languageForm" class="lang-select"> | ||
<div class="d-flex align-items-center"> | ||
<span class="fas fa-globe me-1" aria-hidden="true"></span> | ||
<?php | ||
$link = HTMLHelper::_('link', '#languageSelect', '', ['id' => 'languageForm-current', 'data-joomla-dialog' => '###dialogattr###', 'class' => 'btn btn-link ps-1']); | ||
|
||
// Dialog needs single quotes for attributes, so use single quotes... | ||
$link = str_replace('"###dialogattr###', '\'{"textHeader": "' . Text::_('INSTL_SELECT_INSTALL_LANG') . '", "iconHeader":"icon-language"}\'', $link); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use propper json_encode and html value encoding. htmlspecialchars(json_encode($data)); Also can do without str_replace: $link = HTMLHelper::_('link',
'#languageSelect', '',
[
'id' => 'languageForm-current',
'data-joomla-dialog' => htmlspecialchars(json_encode($data)),
'class' => 'btn btn-link ps-1']); |
||
|
||
echo Text::sprintf('INSTL_SELECTED_INSTALL_LANGUAGE', $link); | ||
?> | ||
</div> | ||
<template id="languageSelect"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can keep it as regular element (just make it hidden), if you want. <div hidden>
<div id="languageSelect">
<div class="mb-3"><?php echo $this->form->renderField('language'); ?></div>
</div>
</div> And set dialog option 'data-joomla-dialog' => htmlspecialchars(json_encode([
'textHeader' => Text::_('INSTL_SELECT_INSTALL_LANG'),
'iconHeader' => 'icon-language',
'preferredParent' => 'body',
])), |
||
<div class="mb-3"> | ||
<?php echo $this->form->renderField('language'); ?> | ||
</div> | ||
</template> | ||
<input type="hidden" name="task" value="language.set"> | ||
<input type="hidden" name="format" value="json"> | ||
<?php echo HTMLHelper::_('form.token'); ?> | ||
</form> | ||
|
||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,6 +111,11 @@ public static function detectLanguage() | |
$browserLang = substr($browserLang, 0, strcspn($browserLang, ';')); | ||
$primary_browserLang = substr($browserLang, 0, 2); | ||
|
||
// Some browser return only "fr" or "de", so let's try to use it like "fr-fr" or "de-de" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. E.g. for English this would not work as there is no There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i did some tests and the only time I could get firefox to return http_accept_header with ONLY the language part and not the region is when the complete version is xx-XX so de-DE returns as de as there is no combination en-EN then firefox would always return the full language eg en-US in short (and assuming my test is accurate) this code is correct and @richard67 concern while valid will never happen |
||
if (\strlen($browserLang) == 2) { | ||
$browserLang = $browserLang . '-' . $browserLang; | ||
} | ||
|
||
foreach ($systemLangs as $systemLang) { | ||
// Take off 3 letters iso code languages as they can't match browsers' languages and default them to en | ||
$Jinstall_lang = $systemLang->lang_code; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ensures that code works as intended in RTL as well AS LTR.
RTL using margin-left
RTL using margin-inline-start