Fieldtype with multi-language variables
Hi,
I'm new to Low Variables so this might be just me not getting this but I couldn't find the answer for this question from the LV documentation nor from here.
I'm building a site for a client with products with multiple colors per product. Products are in 6 different languages. I would like to have a fieldtype where client selects colors for the product from a pre-defined list, say "Blue", "Red", "Black" and so on, and have these correspond to predefined translations of the colors for all 6 languages.
So, if the client selects colors "Blue" and "Red", I could use language variables to show the selected colors on the front end (like: en_blue, fr_blue, sp_blue, fi_blue). This would allow the client to only select colors once per product and for me to easily manage list of translations for those languages.
Is this possible with LV and if so, how should I go about setting this up?
Isko
Replies
Low 10 Jan 2012 16:43
Yes, this could be done. You'll also need P&T Field Pack (free) so you can use its Select Dropdown fieldtype.
* I'm assuming you're setting the language variable in your index.php or config.php. Let's call it global:lang for this example.
* Create a channel field with type P&T Dropdown and call it cf_product_color (for example)
* Add this to the options of the field...
...etc.
* Per color option, create x number of Low Variables, where x is the amount of languages, for example: lv_blue_en, lv_blue_fr, lv_blue_nl, etc.
* In your template, you would then display the right color like this:
Make sense?
isko 12 Jan 2012 10:58
Thanks for the really speedy response!
I have couple of questions to see if I got this right:
- what should I select as the variable type for these variables?
- I have 17 colors and 6 languages, if I got this right, I need to create 102 variables?
Low 12 Jan 2012 11:08
Your best bet is the Text Input variable type. Make sure Early Parsing is turned off.
Yes, 102. To help you create those, you can use the batch-create variables or duplicate group options. Check the docs on managing vars.
For example, you could create a group for 1 of your 6 languages, add the 17 colors to it, making sure the language suffix is at the end, e.g.: lv_blue_en, lv_green_en, lv_red_en... etc. Once created, you can go to the group details and save it as a new group for the second language. Choose to duplicate the vars and replace the suffix with the new language, e.g.: nl. You can do this for each of the 5 remaining languages.
isko 12 Jan 2012 11:32
Got it! Thank you!