0

I am implementing UTF-8 character support in my project. we use template tool kit. In one of the templates I have this hard coded drop down code that is not allowing me to translate the text. here is the code snippet.

<select id="sub_select" name="sub_select">
[% sub_options = [
- { value => 'last', choice =>'translate.$lang.L_Submission' },
- { value => 'all', choice => 'translate.$lang.A_Submissions' },
];
%]
[% INCLUDE dropdown.tmpl
options = sub_options
selected = sub_select
%]
</select>

Where dropdown.tmpl is a centralized file that is used to create the Drop downs all over the application.
I have the liberty to create a new dropdown_UTF8.tmpl, which will support the new type of choices or I can accommodate the new logic into this dropdown.tmpl. Currently when I am trying this with existing dropdown.tmpl, I am getting translate.$lang.A_Submissions and translate.$lang.L_Submission as the choices, where as I am expecting the translated data to be displayed. Can any one help me with this.

dropdown.tmpl:

[% valuekey = valuekey || 'value'; 
   choicekey = choicekey || 'choice'; 
   FOREACH opt = options;
     - value = opt.$valuekey.defined ? valuekey_prefix _ opt.$valuekey : valuekey_prefix _ opt
     - choice = opt.$choicekey or value
%]
[% value = value %]
<option value="[% value %]"[% selected="selected" IF value == selected %]>[% choice %]</option>
[% END -%]
edem
  • 3,222
  • 3
  • 19
  • 45
Ash_and_Perl
  • 356
  • 5
  • 21

1 Answers1

0

Unless I'm missing something, I think the problem here is simply the single-quotes around the values for choice in those hashes. Single quotes will by definition result in what they contain not being interpolated.

Try:

[%  sub_options = [
        - { value => 'last', choice => translate.$lang.L_Submission },
        - { value => 'all',  choice => translate.$lang.A_Submissions },
    ];
%]
RET
  • 9,100
  • 1
  • 28
  • 33