Search the FirstSpirit Knowledge Base
Hello,
In my project, I have many language tabs and page will be activated for few langauges only. I want to find the selected langauge only.
Is it possible to get the selected or activated language in the page through bean shell ?
No, there is no property for this. Could you explain your use case?
Hello Jodeleit,
I have two langauge selected the in the page, is there any way to get the selected language of the page
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
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 ??
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
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.
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.
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
Hello,
has the answer helped you or are there some more questions?
Best regads
Jan