Hi, i have a trilingual site (web, en, tr).
I want to write a snippet which get as input a set of resource IDS from the web langauge and returns a set of ids for that context.
Are you sure you’re not just looking for a way to filter pdoMenu to the context, using the regular publish/hidemenu flags to identify what goes into the menu of a specific context?
I have written a small utility snippet for this, which I call xlang. It uses the current "cultureKey" from Modx, which you set-up by context if you use Babel for the translation.
You call it uncached in your page template or chunk, like this:
[[!xlang? &de=`123` &fr=`456` &en=`789`]]
In the snippet, you retrieve the content of the "de", "fr" or "en" parameter with the following: :
// Return string in current culture key or empty string if not provided to the snippet
return $modx->getOption($modx->cultureKey, $scriptProperties, '');
You can of course define any other language, as long as the Modx cultureKey is defined and you call xlang with the corresponding language code(s).
My actual implementation of the snippet is a little more complex, as I had the requirement to be able to define placeholders in the strings and replace them when calling xlang. I have created a small Gist with my implementation.