Problem/Motivation

Found this while redoing videos for a session. Even if you pick an RTL language, the installer will not be RTL until the database is set up. This is a regression of #1974040: When installing in an RTL language, it should be RTL from profile selection onwards which was already there before.

Proposed resolution

1. Fix it again.
2. Now write tests so it will not break again.

Remaining tasks

  • git instructions for creating patch | Contributor task documentation for creating a patch
  • Review patch to check it fixes the issue, the change is properly documented and for coding standards. Make sure patch stays within scope of just this issue. | Contributor task documentaiton for reviewing patch
  • Add automated tests | Contributor task document for writing automated tests

    User interface changes

    Installer will be RTL from the second step, after picking an RTL language.

    API changes

    None.

  • Support from Acquia helps fund testing for Drupal Acquia logo

    Comments

    YesCT’s picture

    Issue summary: View changes
    Issue tags: +Needs tests

    tagging and adding contributor task documents to the issue summary

    in case someone wants to use a brute force way of finding which commit broke this:
    webchick's how to post http://webchick.net/node/99

    YesCT’s picture

    Issue summary: View changes

    sorry, without specifics, this isn't novice yet. updating issue summary remaining tasks.

    YesCT’s picture

    Issue tags: +frontend

    also tagging front end so our front end focus board has this. (http://www.drupal8multilingual.org/issues/frontend)

    mr.baileys’s picture

    Assigned: Unassigned » mr.baileys

    Using git bisect shows that this got broken when the monster patch from #1862202: Objectify the language system landed.

    I'll write tests and attempt to fix the issue over the next couple of days.

    YesCT’s picture

    thanks, adding that as the parent of this issue.

    sun’s picture

    Title: Drupal 8 installer again not RTL friendly from the start » Early installer is not in RTL after selecting RTL language

    Proper issue title.

    sun’s picture

    I'm also ambivalently surprised that your bisect yielded the language objectification issue. I could have sworn that I'm guilty ;-)

    mr.baileys’s picture

    Status: Active » Needs review
    Issue tags: -Needs tests
    FileSize
    1.84 KB

    I initially also thought #2213357: Use a proper kernel in early installer was the cause, but I double-checked and it was broken prior to that commit. Can you find solace in the fact that if it wouldn't have been broken, your change would probably have broken it? ;)

    Here's a test for this (expecting it to fail), now trying to fix the actual issue...

    Status: Needs review » Needs work

    The last submitted patch, 8: 2240007-8-installer-rtl-ltr-rotfl.patch, failed testing.

    mr.baileys’s picture

    Status: Needs work » Needs review
    Issue tags: -frontend
    FileSize
    3.38 KB

    So I'm able to "fix" this by adding something like:

        // Set the default language to the language selected in the installer.
        $container
          ->register('language.default', 'Drupal\Core\Installer\LanguageDefault')
          ->addArgument(array('id' => <chosen language here>));
    

    to InstallerServiceProvider::register(). However, this seems to not be right approach, since it adds a dependency on a global (the selected language). I also tinkered with a "InstallerDefaultLanguage" class and moved the global there, but it still feels icky.

    (removed frontend tag since this is a backend issue)

    mr.baileys’s picture

    Assigned: mr.baileys » Unassigned
    FileSize
    188.91 KB
    188.28 KB

    Prior to appying the patch:

    After applying the patch:

    (unassigning myself since I will be AFK for a week or so, don't want to hold up progress on this issue)

    Gábor Hojtsy’s picture

    Title: Early installer is not in RTL after selecting RTL language » Regression: early installer is not in RTL after selecting RTL language
    Issue tags: +Regression

    @sun for his installer experience and @plach for his language manager experience would be great reviewers on this one :)

    YesCT’s picture

    I wonder if we should have the opposite test also, that the installer stays in ltr, with a ltr language.

    --
    this is adding docs like @file for the file and docs on methods. see interdiff.

    Gábor Hojtsy’s picture

    The existing installer tests can be extended to ensure the installer keeps in LTR if appropriate. Eg. our German test and/or our default English test.

    mr.baileys’s picture

    Here's a new patch with LTR language direction assertion in the German translation installer test.

    Gábor Hojtsy’s picture

    Status: Needs review » Needs work
    +++ b/core/includes/install.core.inc
    @@ -267,6 +267,7 @@ function install_begin_request(&$install_state) {
    +    $GLOBALS['conf']['language_default'] = $install_state['parameters']['langcode'];
    
    +++ b/core/lib/Drupal/Core/Installer/InstallerServiceProvider.php
    @@ -47,6 +47,13 @@ public function register(ContainerBuilder $container) {
    +    // Set the default language to the language selected in the installer.
    +    if (!empty($GLOBALS['conf']['language_default'])) {
    +      $container
    +        ->register('language.default', 'Drupal\Core\Language\LanguageDefault')
    +        ->addArgument(array('id' => $GLOBALS['conf']['language_default']));
    +    }
    +
    

    I see how you use this global value to pass on this information. However $conf['language_default'] is not anymore used for anything, the site default language is now directly stored on system.site's langcode.

    So IMHO it would be better to use something else to avoid confusion. Is the global value the best way to pass on this info?

    mr.baileys’s picture

    Status: Needs work » Needs review
    FileSize
    3.7 KB
    2.21 KB

    So IMHO it would be better to use something else to avoid confusion. Is the global value the best way to pass on this info?

    Yes, the global is ugly, but I couldn't think of a better, cleaner way to implement this.

    However, I assumed LanguageDefault was an immutable object. Turns out it isn't, so we can just do \Drupal::service('language.default')->set(), making this patch both cleaner and simpler.

    Gábor Hojtsy’s picture

    Looks good from a code points of view :)

    MarkusDBX’s picture

    Reviewing this latest, 2240007-17-installer-rtl.patch

    Before applying the patch:
    Before applying patch

    After applying the patch
    screenshot_with_2240007-17

    Works. It would be perfect if the translation was also correct in step 2, but it may be another issue.

    MarkusDBX’s picture

    Status: Needs review » Reviewed & tested by the community

    I tested the latest patch 2240007-17, it works fine. The translation in step two still needs work, but that may be another issue.

    sun’s picture

    Sorry for not getting back to this earlier.

    Patch looks good to me; just some minor cleanups.

    (Note that I have renames=copies enabled; attached patch still creates the new test; git merely detected that the new file is a copy.)

    webchick’s picture

    Status: Reviewed & tested by the community » Fixed

    Nice catch!

    Can you find solace in the fact that if it wouldn't have been broken, your change would probably have broken it? ;)

    LOL :)

    Committed and pushed to 8.x. Thanks!

    • Commit ace0879 on 8.x by webchick:
      Issue #2240007 by sun, YesCT, mr.baileys | Gábor Hojtsy: Regression:...
    Gábor Hojtsy’s picture

    Yay, thanks!

    Status: Fixed » Closed (fixed)

    Automatically closed - issue fixed for 2 weeks with no activity.