All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

Managing variables for a multi-lingual dropdown

Jonathan Schofield 20 Feb 2012 16:22 question, complete

I'm working on a multi-lingual site with a number of dropdown select menus.

For each dropdown, the options within it need to have a consistent (English) value but the visible text for the option needs to be able to be mapped to a country code variable (eg: 'en', 'fr').

So a given 'en' output might be:

<option value="english">English</option>

But the French 'fr' version of this would be:

<option value="english">Anglais</option>

Can you advise a Low Variables strategy for solving this? Is it a case of using the Select variable type with early parsing and having one for each country code? (Although see my other thread about understanding the Select variable type.)

Thanks for any advice you can offer.

Great tool BTW!

Replies

  1. Low 20 Feb 2012 22:40

    Hi Jonathan,

    As I tried to explain in the other thread, the Select variable type is meant to help you set the value of a variable with pre-defined options. These options aren't variables themselves.

    That said, what you'd need is translations/labels for a certain term, in this case "english", the value of your drop down. You could create a simple Text Input variable called {lv_english_en} with value "English" and one called {lv_english_fr} with value "Anglais". This means you'd have to create quite a few vars: # terms * # languages = # vars (eg. 4 terms * 3 languages = 12 variables). Like this, your site editors can edit the labels.

    To help you create vars like this, you can use the variable suffix option (when you create a variable) or the "Duplicate group" option, which is available in LV 2.0+.

    To generate the dropdown, you could hardcode the options in your template, calling the vars you created:

    <option value="english">{lv_english_{global:lang}}</option>


    ...where {global:lang} is a global variable set in your index.php file and contains the country code.

    Hope that points you in the right direction.

  2. Jonathan Schofield 20 Feb 2012 23:24

    Thanks Low. That makes sense.