Recently I made a QlikView application with multiple languages. I came across a blog post by Charles Bannon: “Handling multiple languages”. Charles describes two scenarios for the use of multiple languages. The first scenario, “translate labels and textboxes within the application and not the actual data”, solved my problem. Charles uses a translation table with an index. He uses set analysis to reference the index number and the language. The expression used is:
=Only({<Index={5}>} [$(=vDataLanguage)])
A good solution, but not very user-friendly. Do you know which translation belongs to index 5?
In this blog post I will rewrite the expression to a more user-friendly and readable formula, and will also explore some other ways of dealing with translations in QlikView.
Method 1: Translation identifier
First, I added the column Text2Translate on the translation table. This is a “translation ID”.
(NOTE: In the example QVW I use an inline table but you can also load an Excel table.)
Second, I created a SelectedLanguage Table:
I add the variable vLanguage, the language which the user selected:
vLanguage: =SelectedLanguage
Now we can rewrite the expression from Charles:
Only({<Text2Translate={‘tUnitPrice’}>} [$(vLanguage)])
The expression is more readable but still not user-friendly.
We can create a variable vTranslate with a parameter ($1) for the text2translate:
vTranslate: Only({<Text2Translate={$1}>} [$(vLanguage)])
We can use this variable to translate labels in QlikView by passing the text we wish to translate as a parameter:
$(vTranslate(‘tUnitPrice’))
Now we have three expressions with the same result; which expression do you prefer?
Be careful though!
We’ve created a data island: the SelectedLanguage table. Read the consequences of using data islands in Rob Wunderlich’s blog post “The impact of data islands on cache and cpu”.
Every time a user switches the language in the application, QlikView recalculates EVERY object on the sheet! I assume a user doesn’t regularly change the language in the application, so the data island doesn’t have to cause any performance problems. If the user does switch the language a lot and it causes performance issues, you can try Rob Wunderlich’s suggestions:
Method 2: Language variable
Create an input box with a new Language variable with constraints:
Method 3: Alternate states
- Go to Document properties -> General tab -> Alternate States button
- Add an alternate state
- Add a list box with the field SelectedLanguage
- Go to List box properties -> General tab
- Change the alternate state from <Inherited> to your new alternate state
- Change the vLanguage variable to =only({Language} [SelectedLanguage])
(Learn more about alternate states here)
Example
I have included all three methods described above in an example file, you can download this using the following link: