Using translation strings in components

I have been trying to solve this problem since this morning, and I know that I am missing something obvious here, but I cannot find it.

We use an XML file that is published on a server that contains translations of all standard words, such as "read more." This is a page with a component that is localized in the corresponding publication.

In our Razor templates, we use the following code below a simple news summary item, which in turn refers to the complete item.

<a tridion:href="@news.ID" class="more" ><%=DefaultLabels.TranslatedTerm(((HomePage)Page).Location, "read_more")%></a>

The fact is that the server tag is working fine, but it is decided how

<tridion:ComponentLink runat="server" PageURI="tcm:15-407-64" ComponentURI="tcm:15-1475" TemplateURI="tcm:0-0-0" AddAnchor="false" LinkText="&lt;%= DefaultLabels.TranslatedTerm(((HomePage)Page).Location, &#34;read_more&#34;) %&gt;" LinkAttributes=" class=&#34;more&#34;" TextOnFail="true"/>

As you may have noticed, it is written as plain text on the page (not surprisingly, because the LinkText parameter is declared as String primarily according to liveDocs).

If i take

tridion:href

href

, ... TCM , .

Razor, linkText, ComponentLink , . , , , TBB .

- , ?

EDIT:

, , , , - , , . , !

+5
2

, :

<tridion:ComponentLink runat="server" PageURI="tcm:15-407-64" 
    ComponentURI="tcm:15-1475" TemplateURI="tcm:0-0-0" 
    AddAnchor="false" LinkAttributes=" class=&#34;more&#34;" 
    TextOnFail="true">
        <%=DefaultLabels.TranslatedTerm(((HomePage)Page).Location, &#34;read_more&#34;) %>
</tridionComponentLink>

TCDL, Taglib/ServerControl

+2

, . .

@helper RenderLink(
    dynamic link,                        // the link to render. Handles components + internal / external links
    string cssClass = null,              // optional custom CSS class
    string title = null                 // optional link text (default is the title of the component being linked to)
    ) 
{
    if(link == null) 
    {
          return;
    }

    if (title == null) 
    {   
        title = link.title;
    }

    string classAttr = string.IsNullOrEmpty(cssClass) ? "" : " class='" + cssClass + "'";
    dynamic href;
    string tridionLink = "";
    string targetAttr = "";

    if (link.Schema.Title == "External Link") 
    {
        href = link.link;
    }
    else if (link.Schema.Title == "Internal Link")
    {
        href = link.link;
        tridionLink = "tridion:";
    } 
    else 
    {
        href = link;
        tridionLink = "tridion:";
    }    

    if(link.target != null) 
    {
        targetAttr = link.target == "New window" || link.target == "Popup" ? " target='_blank'" : "";
    }    

    <a @(tridionLink)href="@href"@classAttr@targetAttr>@title</a> 
}
+8

All Articles