We've been doing more multiligual sites, and we needed a quick way to output the context (language) we're currently in.
Below is the snippet code, yup, that's it. Create a new snippet and call it getContext, done. MODx API Reference.
<?php $contextKey = $modx->context->key; return $contextKey;
So how might you use it?
We used it in getResources templates for "read more" buttons that needed translations. In our case it was "View Bio" but you get the idea.
<a class="button radius nice" href=""> </a>
What this does is, if getContext is = web, that means it's in the defualt context of English; if not we'll assume Spanish.
There might be other ways to do this, but it worked for us.
Turns out there are better ways.
Mark Hamstra from the MODx Team commented:
Or, you can use the existing [ [*context_key (or [ [+context_key) tag!
Another third way, would be to put the bits that need to be translated into the lexicons (System > Lexicon Management), and just use the [ [%some.lexicon.key syntax to add in the multilingual text.