Text list, get text from surtain language.

Ton
2022-04-25
2022-05-08
  • Ton - 2022-04-25

    Hi,

    For my logger i need to get the text from 'en' language.
    To see items in my logger in Japanese or polisch doesn't tell me much.

    To get the text from the Text list i use cmpDynamictext library:
    sText:= cmpDynamictext.DynamicTextGetText(ADR(sAlarmGroup), ADR(sAlarmID))^; //Get name, language dependent
    sDefaultText:= cmpDynamictext.DynamicTextGetDefaultText(ADR(sAlarmGroup), ADR(sAlarmID))^; //Get default name

    The easy way is to put the 'en' text in the default, but this is my alarm ID.

    Is there a way to get from a specific language the text?

    Thanks,
    Ton.

     
  • ludecus

    ludecus - 2022-04-26

    Hallo Ton,

    we use the GetText function of the TextListUtils (TLU) library. The function returns the text in the activated language. In case the text doesn't exist in this language the function gives the text in the default language.

    TLU.GetText(_sTextList,_sTextIndex,ADR(_sTranslatedText),SIZEOF(_sTranslatedText));
    

    We do have 2 default languages and the third language is country-specific. We simple replace the .txt file on the target device.

     
  • Ton - 2022-04-26

    Hi Ludecus,

    Thanks for your input.

    With this function i have the same problem.
    I want a specific language ('en') and not the activated language (might be unreadable if 'jp').

    I don't thinks this function exist.

    Thanks,
    Ton.

     
  • ludecus

    ludecus - 2022-04-26

    Please try this

    VisuElems.cmpDynamictext.DynamicTextGetDefaultText(ADR(_sTextList),ADR(_sTextIndex))
    
     

    Last edit: ludecus 2022-04-26
  • kislov - 2022-04-27

    I do it this way:

    PROGRAM PLC_PRG
    VAR
       xGetText: BOOL;
       sCurrentLanguage: STRING(20);
       sTextListName: STRING := 'TextList';
       sTextId: STRING := '0';
       psText: POINTER TO STRING;
       sText: STRING;
    END_VAR
    
    IF xGetText THEN
       sCurrentLanguage := CmpDynamicText.DynamicTextGetCurrentLanguage();
       // set language what you need
       CmpDynamicText.DynamicTextChangeLanguage('en');
       sText := CmpDynamicText.DynamicTextGetText(ADR(sTextListName), ADR(sTextId) )^;
       CmpDynamicText.DynamicTextChangeLanguage(sCurrentLanguage);
       xGetText := FALSE;
    END_IF
    
     

    Last edit: kislov 2022-04-27
  • Ton - 2022-04-27

    Hi Kislov,

    This is what i was looking for.

    Many thanks!!!

     
  • Ton - 2022-05-08

    This solution takes a lot of performance.
    When for example two alarm bits comes at the same time the second has a delay of few seconds.
    I quess my visu do also get translated, so not a good solution.
    For now i just take default language.

     
    πŸ‘
    1

Log in to post a comment.