Multiple languages with Low Variables

If you’ve ever built a multilingual website, you know just how many bits of text need to be translated. In ExpressionEngine, the logical place to put this content, is in weblogs/channels. However, for some data that might not be appropriate. This is where Low Variables comes in handy.

Multilingual sites in ExpressionEngine 1.6.x often use a Path.php variable to determine the current language. Something like this, perhaps:

$global_vars['country_code'] = 'es';

Let’s take this approach and apply it to Low Variables.

Create a variable for each piece of text that needs to be translated. Make sure Early Parsing is turned off for these variables. In my example, I created these: {low_snippets_payoff_en}, {low_snippets_payoff_es}, {low_snippets_footer_en} and {low_snippets_footer_es}.

Screenshot: Low Variables with text inputs

Then, all you have to do in your templates, is add these variables, combined with the Path.php variable we made earlier:

<p id="payoff">{low_snippets_payoff_{country_code}}</p>

<!-- More code -->

<p id="footer">{low_snippets_footer_{country_code}}</p>

But don’t stop there; all static bits of text throughout your templates can be treated like this. Your users will hug you and send you flowers ’cause they can now edit them without the heartache!

January 22nd 2010 | Add-Ons, ExpressionEngine, Low Variables

Leave a comment



Some html (a, em, strong, etc) allowed.
Email won’t be displayed and takes care of your Gravatar.