Uploaded image for project: 'phpBB3'
  1. phpBB3
  2. PHPBB3-12254

Language switching on Registration page doesn't work for Extensions

    Details

    • Type: Bug
    • Status: Unverified Fix
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.1.0-dev, 3.1.0-a3, 3.1.0-b1
    • Fix Version/s: 3.1.0-b3
    • Component/s: Extensions, Language pack
    • Labels:
      None

      Description

      For a board with multiple language packs installed, at the Registration page, you can switch between languages on-the-fly via pull-down menu.

      Switching languages, however, does not work for extensions, even if the extension has translations for the other languages.

      When switching to a new language, any extension text on the registration page (i.e.: Header nav links) resort to displaying as raw language variables.

      Also, switching back to English, the extension language variables remain as raw lang vars.

        Issue Links

          Activity

          Hide
          VSE Matt Friedman added a comment - - edited

          From what I can see is happening here, the language switching option on the user registration page simply reloads the page, changes the user_lang settings, and then re-loads only the two language files needed for this page in the new language.

          That means any other language content that could be on the page (i.e.: extensions) get left out. That results in their text displaying as raw lang vars.

          Obviously this was fine in the pre-extension era, to let registrants read the terms of agreement in another language offered by the board.

          I hope somebody has a better idea on how to fix this than me. All I can come up with instead is when a user switches a language using the drop-down menu, set a session cookie for their selection, then in the user class, when defining the $user_lang_name and $user->data['lang_name'] use the cookie if it is set, otherwise leave them set to their regular defaults.

          This should allow the entire page to load in the correct languages, including the correct fallback langs for extensions if they don't support the chosen lang. But also, this would allow the user's lang selection to persist throughout the rest of their session as long as they are still a guest. So if they return to the forum, they will continue browsing in the chosen lang.

          something like inside the setup() function, in the else condition (meaning only for unregistered guests):

          $change_lang = $request->variable($config['cookie_name'] . '_change_lang', '', true, \phpbb\request\request_interface::COOKIE);
          if ($change_lang)
          {
              $user_lang_name = $this->data['user_lang'] = $change_lang;
          }
          

          The only downside I see to any of this, if it even is one, is every unregistered guests user setup will always check for the existence of this cookie, and there will be yet another cookie phpBB is using.

          Show
          VSE Matt Friedman added a comment - - edited From what I can see is happening here, the language switching option on the user registration page simply reloads the page, changes the user_lang settings, and then re-loads only the two language files needed for this page in the new language. That means any other language content that could be on the page (i.e.: extensions) get left out. That results in their text displaying as raw lang vars. Obviously this was fine in the pre-extension era, to let registrants read the terms of agreement in another language offered by the board. I hope somebody has a better idea on how to fix this than me. All I can come up with instead is when a user switches a language using the drop-down menu, set a session cookie for their selection, then in the user class, when defining the $user_lang_name and $user->data['lang_name'] use the cookie if it is set, otherwise leave them set to their regular defaults. This should allow the entire page to load in the correct languages, including the correct fallback langs for extensions if they don't support the chosen lang. But also, this would allow the user's lang selection to persist throughout the rest of their session as long as they are still a guest. So if they return to the forum, they will continue browsing in the chosen lang. something like inside the setup() function, in the else condition (meaning only for unregistered guests): $change_lang = $request->variable($config['cookie_name'] . '_change_lang', '', true, \phpbb\request\request_interface::COOKIE); if ($change_lang) { $user_lang_name = $this->data['user_lang'] = $change_lang; } The only downside I see to any of this, if it even is one, is every unregistered guests user setup will always check for the existence of this cookie, and there will be yet another cookie phpBB is using.
          Hide
          nickvergessen Joas Schilling added a comment -

          Didn't we already fix this?

          Show
          nickvergessen Joas Schilling added a comment - Didn't we already fix this?
          Hide
          VSE Matt Friedman added a comment - - edited

          That was a different issue :0

          This issue is entirely limited to the registration page, and the way the registration page on-the-fly swaps out the language set, via a pull-down language selection menu in the upper-right corner.

          Show
          VSE Matt Friedman added a comment - - edited That was a different issue :0 This issue is entirely limited to the registration page, and the way the registration page on-the-fly swaps out the language set, via a pull-down language selection menu in the upper-right corner.
          Hide
          VSE Matt Friedman added a comment -

          Screenshots added. English at default. Note "Rules" in the Navbar.

          Switched to German

          Note appearance of "Rules" has now changed to the L_BOARDRULES output.

          There was a german language pack in the "Rules" extension. This will happen whether there is an available lang pack or not in the extension, because the entire lang system is not being reloaded. Just the two lang files needed by the core for the registration pages.

          Show
          VSE Matt Friedman added a comment - Screenshots added. English at default. Note "Rules" in the Navbar. Switched to German Note appearance of "Rules" has now changed to the L_BOARDRULES output. There was a german language pack in the "Rules" extension. This will happen whether there is an available lang pack or not in the extension, because the entire lang system is not being reloaded. Just the two lang files needed by the core for the registration pages.
          Hide
          nickvergessen Joas Schilling added a comment -

          Should fix it together with PHPBB3-10521 in one go

          Show
          nickvergessen Joas Schilling added a comment - Should fix it together with PHPBB3-10521 in one go
          Hide
          VSE Matt Friedman added a comment - - edited

          Based on reading up on 10521, came up with the submitted patch. Firstly, I did not implement some kind of board-wide quick-language-select menu. Right now, the patch is just patching the existing behavior, which is to have this menu available only to guests on the registration agreement pages.

          The best way to handle seemed to be to store the user's choice in the session table of the DB. So no cookies are needed, no url params being passed around, and this lasts just for the guest's session. We can also reload everything in the new language now, so extensions can show up correctly.

          The way we get the setting to persist beyond just the reg page is the same way that style is handled. We store the change_lang url param to the SID.

          Show
          VSE Matt Friedman added a comment - - edited Based on reading up on 10521, came up with the submitted patch. Firstly, I did not implement some kind of board-wide quick-language-select menu. Right now, the patch is just patching the existing behavior, which is to have this menu available only to guests on the registration agreement pages. The best way to handle seemed to be to store the user's choice in the session table of the DB. So no cookies are needed, no url params being passed around, and this lasts just for the guest's session. We can also reload everything in the new language now, so extensions can show up correctly. The way we get the setting to persist beyond just the reg page is the same way that style is handled. We store the change_lang url param to the SID.

            People

            • Assignee:
              naderman Nils Adermann
              Reporter:
              VSE Matt Friedman
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development