Quote from: BobRay at Aug 26, 2009, 02:16 AM
Second, am I correct in saying that if I wanted to show both English and French language strings on the same page, (say, for a Canadian site), I’d have to load both languages manually into the database with "Import Lexicon" and then, either have no duplicate keys between the two, or switch back and forth using lexicon->load() for each string?
Ugh, you’ve exposed the main problem of the Lexicon structure to date. The answer is that you’d have to switch, and let me explain why:
The current Lexicon API, when load() is called, basically just reads the collection of Entries for that Topic into an associative array, which is found here as a private var:
$modx->lexicon->_lexicon - An array, like _lexicon[key] = value.
So when a new Topic is loaded, it stores the array of strings into the main _lexicon array. It doesn’t store what Topic they came from. This allows me to "share" lexicon entries from different topics; or override existing entries.
However, if you note, this causes a couple problems:
1) There’s no separate array for each language. Now that I think about it, that could easily be fixable; just nest the topics inside a language-specific array. That would fix your switching problem. You would, however, have to manually load the language (if by tags, using the &lang=``) attribute for each secondary language entry you want.
The other problem, which I’m not sure *is* a problem, is:
2) If a 3PC loads a Topic that has an Entry with the same key as a core lexicon entry, it overrides the core Entry for that page. This might not be much to worry about, though.
Anyway, that’s my thoughts. on that.