MODX Community

Lingua - How to handle Chunks

I’m in process of learning Lingua for a project. I’ve got the language switcher working and I’ve got template variables switching translated content. However, I’m not sure how to handle content that I would normally put in chunks or templates

For content that appears on every page for a given language, such as footer content, I don’t want to setup a tv for every page for footer content. Similarly, how to handle text that might be in a template, such as a sidebar heading. Or for a project template used on a lot of project pages there might be the same section titles on each page, e.g. project overview, project background, team members, etc. It seems kind of crazy to setup tv for every bit of translatable text for each page that is the same on every page.

Any suggestions?

1 Like

I can’t give you an answer but I have a couple suggestions. I don’t know whether they will be useful or whether they would play nice with Lingua.

  1. Contexts can be used for these smallish bits of information. We just had a post talking about contexts that will do things like transform the date of a post for example into other languages

  2. I believe you could use other data to do this, like IP address or system language, but I don’t quite know how to go about that

I’m not familiar with Lingua, but rather than TVs, it might work to use language tags, which MODX will replace with the correct string from the appropriate language file.

1 Like


Thanks for this. I’ll have to study that a bit. It’s new territory for me.

I’ve also been thinking I could use output modifiers to insert text based on the culture key. So if culture key is “en” then “hello”, if “de” then “hallo”, etc.

My concern about this approach is efficiency. This project would probably have a 5-6 languages so for each instance of text to translate I’d need to make 6 evaluations. I guessing if I have several instances on a given page it could require 30-40 evaluations, that it would slow the page down quite a bit.

Using the lexicon approach seems more complex to setup and wouldn’t it require the same number of evaluations? But, perhaps it would be a faster method for page load?

What do you think?

1 Like

Yes, lexicon files would be much faster for page loads. In addition, I think you’ll find language strings much quicker and easier to set up than output modifiers. Once you have one language file, you can duplicate it for the rest and just change the strings. You can also run a language file through google translate. It won’t be perfect, but it will do most of the work for you.

Consider this: If you use output modifiers and later add another language, you’ll have to rewrite every relevant tag on the site (if you can find them all). With language strings, you’ll just create a new copy of the language file and translate the strings. It will be used throughout the site automatically.

1 Like

Just wanted to circle back. Using the tutorial in Bob’s Guides, I’ve got this working now so the contents of a chunk will change when the language changes. At first I got the lexicon entries to display for a specific language, but I couldn’t it to switch when the language selection was made via the Lingua Selector. Finally, I figured out that I needed to use the culture key in the language tag to dynamically specify the language needed.

[[%tb_project-specification? &language=[[!lingua.cultureKey]] &namespace=test &topic=default ]]

I’m good to go. Thanks for the setting me in the right direction!

1 Like

Thanks for the details. I’m sure they will help others. :slight_smile:

1 Like

I have a follow-up question. Once I’ve translated some form fields and the form is submitted. How do I send confirmation emails to the sender with the correct translation?

Also can I assume the thank you page specified in formit be translated into the correct language like any other page?