We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • discuss.answer
    • 7923
    • 4,213 Posts
    Quote from: BobRay at Feb 23, 2013, 10:16 PM
    For the front-end login form, set full language tags in the Tpl chunk and specify that Tpl chunk in the Login snippet tag,
    The login_cannot_locate_account text is not in the chunks, it's an error msg coming from the snippet to the error tpl chunk into [[+msg]] placeholder based on situation.

    Quote from: BobRay at Feb 23, 2013, 10:16 PM
    unless you want the language to apply to the whole web context, in which case, create a cultureKey Context Setting for the web context. The setting should contain the two-letter code for the language ('en', 'de', 'fr', etc.).
    No, I don't want to make a change that effects the whole context, just this one snippet call. And the culture is the same for every user, just need to print different text from the lexicon keys based on the user's usergroup. If I would want to make the cultureKey setting, what would you suggest to use as the key when all users are really from the same culture. Copy the 'en' culture to 'de' for example and use that or what?

    Quote from: BobRay at Feb 23, 2013, 10:16 PM
    For the Manager login form, it's going to use the cultureKey System Setting because it doesn't know who the user is (and why wouldn't you want the manager language to be used in the Manager login form?).
    I do want the manager language to be used in the login form, but the Login snippet uses the same lexicon key. In front end, the username for the users is an email address and in the manager it's a normal username. So when I change the lexicon keys for the front end to reflect that users login with an email address, it also changes the texts for the manager. Then I would like to define some keys for only the manager back to the originals.

    Quote from: sottwell at Feb 24, 2013, 02:53 AM
    To get a different lexicon key for the "web" context, go to System -> Contexts, and right-click the web context to update it. Create a new context setting, and put in a new cultureKey setting. Take a look at the system cultureKey setting in the "Lexicon and Language" area of the system settings to see what it should look like. This would change it for the entire front-end, however, not just for the one snippet.
    Thanks. That would change it to the entire front-end so it's not a valid option for my situation.

    I thank you both for trying to help me with this. It seems that it's not possible to do what I want. I also think that it's a bad design for a Snippet to use lexicon entries from the core.. can lead to all kind of mess.

    I solved this problem by simply adding logic to the Login error Tpl. If the [[+msg]] has the content of login_cannot_locate_account and the user is in certain user group, it returns different text (my own custom key via lexicon tag).

    Thank you!


      "He can have a lollipop any time he wants to. That's what it means to be a programmer."
      • 3749
      • 24,544 Posts
      It's an unusual situation, and I agree that it should be easier to have the two use different language settings.

      I appears that the Login snippet uses the core setting because that string doesn't exist in the Login package lexicon files. You might try adding this to the core/components/login/lexicon default.inc.php files:

      $_lang['login_cannot_locate_account'] = 'whatever';


      It might use that instead of the core value, but only for front-end logins. If it works, you should submit it as a feature request or a bug report.

      You'd have to clear the site cache before it would take effect.

      One last thing to try (that would almost certainly work) would be to modify the login class file and add a language spec. in the lexicon->load() call that uses the language property in the $scriptProperties array if it's set. That way you could put &language=`de` in the login snippet tag. Something like this:

      [[!Login? &language=`de`]]


      $language = isset($scriptProperties['language'])? $scriptProperties['language'] . ':' : '';
      $this->modx->lexicon->load($language . 'login:default');
      


      This is how the login class should have been written to begin with, IMO.

      In summary, a big part of your problem is caused by two oversights in the code. First, the login_cannot_locate_account language string was left out of the Login lexicon files. Second, the $lexicon->load() call in the login class file has no language option. Those would make for a nice pull request for the Login package if you've got the energy. wink

        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting