Translate Select Attribute Values

Permalink
Hello,

I'm having trouble displaying translated select attributes values on a site I'm working on.
The values appear in the Translate Site Interface but don't update on the site. Lots of other strings are translating fine, but not attributes. Is there something else I need to do?

I already tried wrapping in the template with t($value) and tc('SelectAttributeValue', $value ) but that returns empty.

Any suggestions?

Thank you

GBNT
 
GBNT replied on at Permalink Reply
GBNT
Any help on this issue would be great. Having to duplicate each tag is the only alternative I can find right now.
LucaBn replied on at Permalink Best Answer Reply
LucaBn
This discussion is old, but I had the same problem recently.
When you use
tc('SelectAttributeValue', $value );
the variable $value must be a string, otherwise it will not work.

So, I solved the problem doing this:

$value = $page->getAttribute("my_select_attribute"); // now $value is an object
$value = "".$value; // now $value is a string
tc('SelectAttributeValue', $value );


Hope it will help!
goesredy replied on at Permalink Reply
goesredy
Use this instead:
$translated = $page->getAttribute("my_select_attribute", 'display');
LucaBn replied on at Permalink Reply
LucaBn
You are right, this is the right way to do it.