Hello all. My idea is rather simple, I think. I have 2 pretty much similar tables content that is a standart modx table and translations wich is identical but has an other column called locale. What I want to do in my snipped is somethin lake this:
$sql = "select * from translations where local='en'";
$sql="select * from content";; //with current page_id etc...
Sorry for bad syntax this was written pretty much on laps just to show an idea. I do understand the consiquence of it and thought may be I could just paste a content functionality into a snippet or is there a better way to achive it? Or where are those finctions exist in modx core?
what you are asking for, is basically, what migxMultilang or Lingua does. Fetching translated content. like resourcefields or TVs from Translation Tables. But I didn’t touch migxMultilang for years and Lingua isn’t maintained any more, as far as I know.
I’m using Babel for translating Resources, because its so much cleaner to have separate Resources for each language, IMO.
From your last question, I assume you want to replicate the functionality of Lingua for MODX3.
I tried to install the current version of Lingua on MODX3 and although it throws some errors during the installation, most of the functionality still seems to work.
So it’s probably easier to make some fixes to Lingua than to program something entirely new.
migksMultilang is not mainteined eather. I tryed to use babel but the main problem for me is that it sims you cannot add an other language without reinstalling the plugin. What is planned originally is to create seviral languages for content and use automatic translation for them like Google Microsoft translate etc. One part of it is already done I have a table with localization and can provide a values there with manager pannel.
It’s seems to me that you are trying to replicate the functionality of the snippet “lingua.getvalue” in Lingua.
Maybe look at that code for inspiration.
In the snippet you can access the current resource with $modx->resource.
You can query data from your custom table with getObject() or getCollection().
Maybe you have to call addPackage() first, so that you can access your custom tables with xPDO.