Any advice on howto use Exists/GetValue/Evaluate with localization?

Hello,

how would you recommend to use the stated functions (Exists/GetValue/Evaluate) in an “user”-localized environment.

Situation:

Dependeng on the culture the user has associated in our application, we start the Designer/PrintJob with the according LCID and add the DesignerLanguage and Dictionary entries.

Simple Example:


var culture = new CultureInfo(“en”).LCID; //Could be any different language here

//Clear dictionary and DesignerLanguages and set values
LL.DesignerWorkspace.DesignerLanguages.Add(culture.LCID);

Ll.Variables.Add(“MyItem”, “MyValue”);

//In case of culture fr, the Identifier would be “MyItemFR” and so on
Ll.Dictionary.Identifiers.Add(“MyItem”, “MyItemEN”, culture.LCID);

So now in the Designer, the user can use “their” localization to access the variable, when a user with a different culture starts the Designer he/she sees the correct/localized representation.

Designer and Print show the correct output. Great!

Now we have a special situation where a Variable could be present, so userEN adds the following Expression:

If(Exists(“MyItemEN”), True, False).

The Designer shows “True”. But The PrintJob(e.g. Preview) shows false!

And when userFR starts the Designer he also sees false, because userFR does not have the identifier “MyItemEN”.

So the solution for PrintJob would be to use:

If(Exists(“MyItem”), True, False). //The actual id/name of the variable

But this has two drawbacks.

  1. Then the Designer shows “false”, because he searches for the localized value.

  2. The user does not now the actual id/name of the variable.

(This example with EN is really simplified, the actual identifiers are much more complicated and

nested, the user can not really know them.)

Here are the questions:

  1. Is there a “simple” way to provide both information’s in the Designer (the localized-id and the actual-id), so the user can at least see them when using functions like “Exists”?

  2. Why does the Designer only evaluate the localized values? I would assume that the none-localized values should also be evaluated correctly. (In this example the “MyItem”)

Maybe this is even a bug and should be evaluated correctly?

Any advice for me, how to achieve the requirement?

Best regards,

Alexander Schneider

Hello Alexander,

welcome to the List & Label forum.

  1. Use the VarHelpText event here and pass the info about the “real” name in the tooltip.
  2. We will have a closer look at this. I will keep you updated here.

Here we go with more information :slight_smile:. As Thomas outlined, the VariableHelpText event is the way to go for the description. You’ll get the global name passed in and can add it as a tooltip. A possible handler would be

private void LL_VariableHelpText(object sender, VariableHelpTextEventArgs e)
{           
    e.HelpText = $"Original Name: {e.Name}";
}

resulting in this tooltip in the Designer:

image

In order to actually use the Exists function with this global key, you need to switch the option LL_OPTION_VARLISTLOOKUP_ALLOWS_GLOBALNAME (value 300) to true. By default, this global lookup is disabled for performance reasons. However, if you keep your data reasonably small and only set this option for the designer, you shouldn’t really have to worry. Thus, call

LL.Core.LlSetOption(300, 1);
LL.VariableHelpText += LL_VariableHelpText;

from your code to set the option and wire up the event handler. That should do the trick then.

Hello,

thank you for the recommendations.

Using VariableHelpText is definitely useful, actually we are already using it, I simply haven’t thought of this :sweat_smile:.

Enabling the “LL_OPTION_VARLISTLOOKUP_ALLOWS_GLOBALNAME”-Option also shows the correct value in the Designer-Preview.
We will have to evaluate the performance drawbacks in this case. We have use-cases with a lot of variables, which caused performance problems in the Designer in the past. But this is a different topic.
Probably we will simply let the user decide if they need this option for the specific cases.

Thank you for your help, I can solve the problem with the provided information’s :slight_smile:.

Best regards
Alexander Schneider

1 Like