Hi, recovering this from a long time but i want to achieve is multilanguage
this is my structure
i'm always messing with if's and get's and nulls and can't get it straight, sorry
<itemdata name="name1" youtube="-someId">
<language name="pt" sound="pt/17.mp3" text="name 1 in pt" />
<language name="en" sound="en/17.mp3" text="name 1 in en" />
<language name="es" sound="es/17.mp3" text="name 1 in es" />
</itemdata>
<itemdata name="name2" youtube="otherId" text="testname2">
<language name="pt" sound="pt/18.mp3" text="name 2 in pt" />
<language name="en" sound="en/18.mp3" text="name 2 in en" />
<language name="es" sound="es/18.mp3" text="name 2 in es" />
</itemdata>
heres the action
%1 is the name of itemData
%2 is the attribute to get in the language
the current language is in "lang" variable
<action name="getLanguageContent">
if (lang === null ,
set(lang , 'ptPT');
);
subtxt(justLanguage , lang , 0 , 2) ;
tolower(justLanguage);
set(defaultLabelId , calc('itemdata[%1].%2' )) ;
set(labelId , calc('itemdata[%1].language[' + lang + '].%2' )) ;
set(labelIdNoCountry , calc('itemdata[%1].language[' + justLanguage + '].%2' )) ;
set (labelIdResult , get(labelId));
set (labelIdNoCountryResult , get(labelIdNoCountry));
set (defaultLabelIdResult , get(defaultLabelId));
if (get(labelIdResult) == get(labelId) ,
if( get(labelIdNoCountryResult) == get(labelIdNoCountry) ,
set ( %3 , defaultLabelIdResult );
,
set ( %3 , get(labelIdNoCountryResult) );
)
,
set ( %3 , get(labelIdResult) );
);
</action>
the supposed behaviour would be
if language is ptPT go check if there is a "language" with name = ptPT.
- if there is, check if there is the attribute %2.
- if it exists return the value of it.
- if it does not exists check for the presence in the language pt
- if it does not exist return the "root" value
getLanguageContent('name2' , 'text') would return testname2 because there is no more specific language to it (there is no language ptPT or language pt with that attribute.. so it gets the top one
getLanguageContent('name1' , 'sound') would return pt/17.mp3 because there is no more specific language to it (there is no ptPT so it ould get the pt
if tried with
=== null
!= null
this version is equal to the "get" of the parent variable because i see in the trace they are the same
i dont know what to do more
trace of the resultvariable that are set prior to the If's
INFO: 1 itemdata[name1].language[ptPT].text
INFO: 2 name 1 in pt
INFO: 3 itemdata[name1].text
trace of %3
INFO: itemdata[name1].language[ptPT].text
it is more an IF problem and variable presence problem than language but.. sorry.. i cannot find a way for this to work
hope someone helps
thank you for your time