Passing variable to antl


#1

Hi,

Trying to pass a variable to ant like this

{{ antl.forLocale(lang).formatMessage(my_var) }}

my_var is coming from a database field.

How should I do it?


#2

I had the same issue, have any solution ?


#3

No I don’t


#4

Do you get any errors? Since it should work fine


#5

I find the solution. the problem is the key doesn’t exist, so, you must verify is the key exists. i made a try/catch to check. and it’s working now

try {
  fieldName = Antl.forLocale('zh').formatMessage(`fields.${errors[i].field}`);
} catch (e) {
   fieldName = errors[i].field;
}