modxbot / migrate

A testground for migrating issues and other such fun
0 stars 0 forks source link

Loading lexicons in manager from other language then the manager_language #7262

Open bertoost opened 12 years ago

bertoost commented 12 years ago

bertoost created Redmine issue ID 7262

I have made a component where you can add titles to entries, these titles are stored in the lexicon table, so $modx->lexicon() can be used for this. In the manager pages you can select an available language from a dropdown to see and modify the titles. This language can be different then the manager language is. To let this work I have done this inside the getlist processor (for example);

$lang = 'en'; // default
if(!empty($language) && is_dir($modx->mycmp->config['lexiconPath'].$language)) {
    $lang = $language;
}

$modx->lexicon->load($lang.':mycmp:mytopic');

In 2.1.5 I have seen the lexicon->load() function is a bit different. The array where the lexicons are stored in is in 2.2 modified with $this->_lexicon[$defaultLanguage] and here the $defaultLanguage is always de manager_language and by default set to "en". This isn't right! Because now I cannot load other languages... at least; the array with other language topics is merged with the "en" array and not with the language array I want.

This seems a bug to me! Can you confirm that?

BobRay commented 12 years ago

bobray submitted:

Two possible solutions:

  1. Use $modx->lexicon('whatever', array(), $language) in all cases.
  2. Put this above the $lexicon->load() call:

    $modx->setOption('cultureKey', $language);

MarkH commented 12 years ago

markh submitted:

What about this:

$modx->lexicon->load('nl:namespace:topic');
bertoost commented 12 years ago

bertoost submitted:

That is what I do Mark, only the language code is dynamic because I want them to be able to see all the languages that are possible. As the docs suggest this should work (and did before) but as you can see in my original text and screenshot there's a bug in the code.

bertoost commented 12 years ago

bertoost submitted:

Just remembered myself to test this again; but all suggested options doesn't work. Please see the attachment and debug it a little

bertoost commented 12 years ago

bertoost submitted:

This is working for me, but I'm still of the opinion this isn't right..

$modx->setOption('cultureKey', $lang);
$modx->lexicon->load($lang.':mycmp:mytopic');
bertoost commented 11 years ago

bertoost submitted:

Still not working in 2.2.8-pl

Using it like RTFM says doesn't work. The cultureKey setting is overruling anyway. Would be great if this can be fixed sometime.

bertoost commented 11 years ago

bertoost submitted:

It's not that the lexicons from the given language are not working, they are loaded well.. but because the $modx->lexicon() method ends on the "cultureKey" setting every time, it will never show the one who's default. Even because $modx->getOption() pulls from context-settings and not from system-settings itself.