Zum Hauptinhalt gehen

Is it possible to find the selected language in page

Kommentare

9 Kommentare

  • Zendesk API User
    Author: Peter_Jodeleit - 3/7/2014 15:17

    No, there is no property for this. Could you explain your use case?

    0
  • Zendesk API User
    Author: vasanth - 3/11/2014 9:26

    Hello Jodeleit,

    I have two langauge selected the in the page, is there any way to get the selected language of the page

    0
  • Zendesk API User
    Author: teichmann - 3/11/2014 13:09

    Hello,

    on page level this option means whether a page in this language is fully translated or not.
    When you already have the page object, there is a method for that which returns a boolean:

    myPageObject.isTranslated;            //from Master langauge

    myPageObject.isTranslated("EN")  //from a specific language; english here 

    Does that help you?

    Regards,

    Jascha

    0
  • Zendesk API User
    Author: vasanth - 3/12/2014 8:44

    Hello Teichmann,

    the above example is fine for you few language but i have 15 languages in my project and i have to write many if's. Is there any way to avoid that ??

    0
  • Zendesk API User
    Author: marro - 3/12/2014 9:41

    Hello,

    you can iterate through the languages of your project, check for each language if it's translated (as Jascha pointed out), and save these languages in a list. So it doesn't matter how many languages you have.

    Best regards

    Donato

    0
  • Zendesk API User
    Author: phillip_austerf - 3/12/2014 13:16

    Hello,

    in which context do you want to trigger the bean shell script? What is your intention?

    If you want to get the current form language (as your screenshot suggests) this might be difficult.

    Cheers,

    Phillip.

    0
  • Zendesk API User
    Author: vasanth - 3/18/2014 13:13

    Hello All,

    I got the code from Mr. Culley. please find the below code 

    $CMS_FOR(for_lang,#global.project.languages.filter(x->#global.page.isTranslated(x)))$

        

                 <a href="$CMS_REF(#global.node,lang:for_lang)$">

                        $CMS_VALUE(for_lang.name)$

                 </a>

    $CMS_END_FOR$

    the abiove code is to filter only the selected language for the page.

    0
  • Zendesk API User
    Author: teichmann - 3/20/2014 10:37

    Hello,

    in beanshell you can get your languages via a LanguageAgent. You can get your LanguageAgent from the scriptContext, for example:

    languageAgent = context.requireSpecialist(LanguageAgent.TYPE);

    then you can get the languages with:

    languages = languageAgent.getLanguages();

    Finally you iterate through your languages and check if they are translated or not:

    for(lang : languages){

         if (myPageObject.isTranslated(lang)){

              //do something if it is set as translated

         }else{

              //do something if the page is not set as translated for this language

         }


    Is that what you intended to do?

    Regards,

    Jascha

    Nachricht geändert durch Jascha Teichmann

    0
  • Zendesk API User
    Author: kohlbrecher - 4/1/2014 9:29

    Hello,

    has the answer helped you or are there some more questions?

    Best regads

    Jan

    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.