MODX is a PHP based, open-source CMS. It has built-in support for backend localization, but doesn’t offer frontend localization out of the box. Lingua is a package known for displaying a lexicon switcher on the frontend. It was made to support multilingual websites.
In this blog, I will illustrate how Lingua works.
There are several extras, or packages, that were developed to provide localization for MODX, the most popular one is Babel. The problem with Babel, is that it requires a context for each language where resources can be duplicated for each.
While this process might be helpful in some cases, it’s lengthy and unmaintainable for large CMSs with many resources and multiple language implementations. In order to estimate how much work is needed to implement translation using contexts, multiply the number of translatable resources in your CMS (resources and Template Variables) by the number of target languages.
Lingua avoids contexts by implementing its own tables for translations. Lingua was based on the translation package, but since translation is still in beta, Lingua has headed in a different direction.
How Lingua Works
If you implement multiple translations of your resources then you will need a language switcher on the frontend.
To be able to use Lingua, you need to:
Add one setting to your context setting:
Lingua custom manager page is provided for you to select which languages (translations) will be used.
Lingua has its own set of predefined languages, but you can add any language as needed.
For the switcher to show up on the frontend, the Lingua.selector has to be used to show lexicon switcher.
Lingua clones resource content and all defined Template Variables (TVs), but doesn’t support custom TVs created out of the MODX TV database as mentioned in this documentation. So the process is down to providing translation of each resource from CMP.
Apart from mix ups with contexts, Lingua saves translations in its own Lingua tables, where site content and template variables are translated into targeted languages.
The outlined parts of the illustration above hold the translated values of site content and template variables, so it is very important not to embed translatable elements into chunks or hard code strings in snippets because they will not be translated. Lingua doesn’t support translatable chunks at this time.
MODX globalization and localization can be implemented in several ways, which one best suits you is based on your needs. Lingua comes in handy when it comes to medium to large CMSs that adopt MODX official development best practices.
Further GPI Resources on Translation Connectors:
You may also find some of the following blogs useful:
Please feel free to contact GPI at email@example.com with any questions about our language and technology services. Also let us know if you have any interesting blog topics you would like us to cover in our future blogs.
About the Author
Rabab is a native Arabic speaker from Cairo, Egypt. She has over 12 years’ experience in software and websites architecture and implementation using open source programming tools including PHP, MySQL as well as jQuery, JSON and Ajax. She has served with various companies including Pyramid Technologies, Link-Dot-Net and InTouch Communications as a Programmer, Systems Engineer – Developer and Lead Web Developer. She earned her B.Sc. Degree in Economics with a minor in Computer Science from Cairo University. She completed a SSDP Diploma from the Information Technology Institute (IDSC), The Cabinet and is a certified Cloud Business Associate and a Microsoft Certified Professional (MCP, MCAD and MCSD.NET).More Content by Rabab Malek