CRM-5493 Drupal's locale language switch doesn't change CiviCRM's locale

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Trivial
    • Resolution: Fixed/Completed
    • Affects Version/s: 3.0.2
    • Fix Version/s: 3.1
    • Labels:
      None

      Description

      CiviCRM and Drupal both provide language switching blocks. To change locale, both had to be changed by user. This patch makes the Drupal one work for CiviCRM as well.

        Attachments

        1. locale_switcher.diff
          3 kB
          Joe Murray
        2. locale_switcher.diff
          2 kB
          Joe Murray

          Activity

          [CRM-5493] Drupal's locale language switch doesn't change CiviCRM's locale
          Joe Murray added a comment -

          Updated to preserve query string on uri. NB: I'm not sure about the security needs on this - please review if I have used check_plain correctly.

          Cheers,
          Joe

          Piotr Szotkowski added a comment -

          Joe, is there any reason why this should be done in civicrm.module rather than in CiviCRM 'proper'?

          What I had in mind when I introduced CRM_Utils_System_Drupal::getUFLocale() was to get the proper locale from Drupal and apply it to CiviCRM (if it's set to inherit the CMS language). With current trunk (you should be able to verify this on sandbox.civicrm.org), when I check the 'inherit CMS language' and switch Drupal languages both CiviCRM menu and CiviCRM contents change.

          Does your patch simply addresses this for 3.0, or is there something I'm missing and there's a bug on 3.1 (currently, trunk)?

          Joe Murray added a comment -

          I would like to test this in 3.1 sandbox but the demo account doesn't have privilege to add languages on the Drupal side. Could you add francais for me or enable me to?

          I wrote this patch when the first one you mentioned on http://forum.civicrm.org/index.php/topic,9612.0.html, r25112, didn't fix the problem on my 3.0.2 install. I continued to be able change CiviCRM and Drupal languages independently of each other using the two switcher blocks

          The second patch mentioned, r25112, seemed to be an option not necessary for the first to work, so I didn't install it. As a result, my testing with only the first may have been inadequate. However, no one indicated in the forum that the patch had fixed it for them and it wasn't working for me.

          I too would prefer to have this done under the hood in CiviCRM if you can get that to work. I just stapled the approach used in the CiviCRM language switching block to the Drupal core local language switching block and that seemed to work, and to be a good Drupalish hook implementation.

          On another note, I was wondering as I made my patch that using only &lcMessages=xx_XX may not change date, monetary and other localizable formats, but I haven't investigated. I will shortly want to have dates localizable on a multilingual site eg December 9, 2009 <> 9 decembre 2009. I trust you know that changing the one setting will change them all.

          Piotr Szotkowski added a comment -

          Joe: I added French (as a Drupal language) to sandbox; please verify whether the language changes as expected (with/without inheritance) and whether the menu gets rebuild on your machine.

          You raise a very good point about the fact that the localisation settings should follow language changes; unfortunately, I don't think we have a per-language date formats in CiviCRM (not even in mutlilingual sites, unfortunately). If you could verify and file a separate issue for that it would be most appreciated.

          Joe Murray added a comment -

          I just went to the sandbox and tried switching CiviCRM language using the language switcher. The Drupal menu and homepage did not change language. As the Drupal locale language switching block is not enabled, I couldn't test whether it was still broken as well.

          Piotr Szotkowski added a comment -

          I'm sorry, I forgot the language module needs a bit of hand-holding in our setup.

          I think I managed to enable the Drupal language switcher, and made CiviCRM inherit the language. Switching to French works for me.

          (The sandbox may reset at Wednesday midnight PDT, so in about sixteen hours. I'll re-fix if it does.)

          Joe Murray added a comment -

          It appears you have enabled French in Drupal without installing French strings for core, as core menu items and tabs are not translated. This may have confused me earlier.

          I see that when the Drupal language switcher is used, which merely inserts /fr in the path, that the CiviCRM content changes to French as it should. I assume that if Drupal is configured to insert a language code into the path for the default language it will also work (eg /en).

          Is there a patch I can install on a 3.0.x to test it further?

          Piotr Szotkowski added a comment -

          As I wrote in that forum thread - I think r25112+r25142 were all I did to implement this in CiviCRM 3.1.

          Piotr Szotkowski added a comment -

          I'm closing this for now as fixed in 3.1 so it doesn't hold up the 3.1 queue - but I'll reopen if there are any issues.

            People

            • Assignee:
              Piotr Szotkowski
              Reporter:
              Joe Murray

              Dates

              • Created:
                Updated:
                Resolved: