Working with cultures in a transformation

Alistair DeJonge asked on August 31, 2016 18:19

Here is my dilemma:

On a site with multiple cultures, the client wants the back-end form to have a URL selector instead of a Page selector to be able to have a choice between internal and external links. The XML transformation code deciphers where it's external or internal by doing a query for NodeAliasPath, and if internal, uses some of the internal page properties to populate the web page.

With cultures on, if the page is internal it will add the culture name (e.g. en-us) to the beginning of the URL string and the query returns NULL. I can trim the culture from the URL and the do the query, but then the content returned will be that of the default culture and will not be translated.

Is there a way to translate the content back to the current culture after the query?

Example code:

    {% if(!String.IsNullOrEmpty(CLP_Grid1)){ %}
    {% doc1 = Documents.WithAllData.Where("NodeAliasPath='" + CLP_Grid1.Substring(6) + "'")[0] %}
    <div class="landing-grid-img">
        <img src="{% !String.IsNullOrEmpty(CLP_GridImageOverride1) ? CLP_GridImageOverride1 : doc1.General_Thumbnail %}" />
        <span class="action--arrow">{% !String.IsNullOrEmpty(CLP_Title1) ? CLP_Title1 : doc1.DocumentName %}</span>
        <div class="overlay">
            <div class="expand">
                <p>{% !String.IsNullOrEmpty(CLP_Title1) ? CLP_Title1 : doc1.DocumentName  %}</p>
                <div class="truncate desc">{% !String.IsNullOrEmpty(CLP_GridCaption1) ? CLP_GridCaption1 : doc1.General_Description %}</div>
                <a href="{% CLP_Grid1 %}">{% !String.IsNullOrEmpty(CLP_GridLinkText1) ? CLP_GridLinkText1.ToUpper() : "LEARN MORE" %}</a>
                <a class="close-overlay hidden">x</a>
    {% } %}

Correct Answer

Alistair DeJonge answered on August 31, 2016 19:19

I found my answer. I can use


to translate it to the current user's culture.

0 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.