0

I have a DE with 4 Languages that is used as a lookup and a segment(list) with 10 Languages. I am trying to say that if they language is not found in my DE then set the language to "en" but I seem to be going wrong somewhere.

This is my code

%%[ 

var @DEColumn1,@DEColumn2, @lang, @country,@DefaultLanguage
set @lang = AttributeValue("Language")
set @country = AttributeValue("Country")
SET @DefaultLanguage = "en"
set @DEColumn1 = Lookup("html4", "text", "Language", @lang) 
set @DEColumn2 = Lookup("html4", "Image", "Language", @lang) 



IF(@lang == "en") or (@lang == "nl") or (@lang == "fr") or (@lang == "de")

THEN
        SET @Status = "OK"
        ELSE
        SET @lang = @DefaultLanguage
        SET @Status = "OK"          
    ENDIF
]%%



DEColumn1(HEADER) is %%=TreatAsContent(@DEColumn1)=%%
<br><br>
DEColumn2(IMAGE) is %%=TreatAsContent(@DEColumn2)=%%
3
  • what id DE? Is that Developer Edition?
    – Patlatus
    Commented Oct 12, 2016 at 10:32
  • DE = Data Extension
    – lyslexic
    Commented Oct 12, 2016 at 12:11
  • so essentially i'm trying to say... IF [AT]lang = en or de or fr or nl then use [AT]lang ELSE use the default which is en
    – lyslexic
    Commented Oct 12, 2016 at 12:34

2 Answers 2

0

I figured it out.

%%[ 

var @DEColumn1,@DEColumn2, @lang, @country,@DefaultLanguage
set @lang = AttributeValue("Language")
set @country = AttributeValue("Country")
SET @DefaultLanguage = "en"




IF(@lang == "en") or (@lang == "nl") or (@lang == "fr") or (@lang == "de")

THEN
    set @DEColumn1 = Lookup("html4", "text", "Language", @lang) 
    set @DEColumn2 = Lookup("html4", "Image", "Language", @lang) 
    ELSE
    set @DEColumn1 = Lookup("html4", "text", "Language",  @DefaultLanguage) 
    set @DEColumn2 = Lookup("html4", "Image", "Language",  @DefaultLanguage) 
ENDIF

]%%

0

You could also do it based on your lookup, which may be a better option, rather than using hard-coded language codes:

%%[
var @rows, @row, @rowCount, @lang, @country, @defaultLanguage, @text, @image

set @lang = AttributeValue("Language")
set @country = AttributeValue("Country")
set @DefaultLanguage = "en"

set @rows = LookupRows("html4","language", @lang)
set @rowCount = rowcount(@rows)

if @rowCount > 0 then

    set @row = row(@rows,1) 
    set @text = field(@row,"text")
    set @image = field(@row,"image")

else

    set @rows = LookupRows("html4","language", @DefaultLanguage)
    set @rowCount = rowCount(@rows)

    if @rowCount > 0 then

        set @row = row(@rows,1) 
        set @text = field(@row,"text")
        set @image = field(@row,"image")

    else

      outputline(concat("<br>no row found for default language: ", @DefaultLanguage))

    endif

else

  outputline(concat("<br>no rows found"))

endif
]%%
<tt>
<br>@DefaultLanguage: %%=v(@DefaultLanguage)=%%
<br>@lang: %%=v(@lang)=%%
<br>@text: %%=v(@text)=%%
<br>@image: %%=v(@image=%%
</tt>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .