modX.lexicon
Last updated Oct 14th, 2026 | Page history | Improve this page | Report an issue
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$194 per month—let's make that $500!
Learn moremodX::lexicon¶
Returns a processed Lexicon entry.
The method itself always returns a string or null. The property $modx->lexicon of the same name holds the modLexicon service object — PHP allows a property and a method to share a name.
Syntax¶
string|null lexicon (string $key, [array $params = array()], [string $language = ''])
$key(string) lexicon key. required$params(array) values substituted into the placeholders of the entry$language(string) language key; thecultureKeyvalue is used by default.
Returns the translated string. Returns null if the entry does not exist or the lexicon service has not been initialized. In that case the log gets a “Culture not initialized; cannot use lexicon.” error.
Example¶
Output the translation of the welcome_message entry with the name Placeholder filled in:
echo $modx->lexicon('welcome_message', array('name' => 'John'), 'en');
The example assumes a lexicon entry with a name placeholder:
$_lang['welcome_message'] = 'Hello [[+name]]! How are you today?';
See Also¶
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$194 per month—let's make that $500!
Learn more










