COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Cognos Administration => Topic started by: michal on 23 Aug 2013 11:13:23 AM

Title: Change language (product and content) via a URL
Post by: michal on 23 Aug 2013 11:13:23 AM
hi folks

we would like to have a url link to switch languages (English / French) without having to go to user preferences, or changing locale of browser or OS.

can this be done?   have any of you folks try to do this?

we have tried appending &lang / &m_productlocale / &m_contentlocale  etc with little success :(

anyone out there have come across this bridge?
Title: Re: Change language (product and content) via a URL
Post by: Grim on 23 Aug 2013 12:39:19 PM
I don't think Language is available as it is stored as a preference in the CS, but I could be wrong.

Check the following link for more info on Parameterized URLs.
http://www.ibm.com/developerworks/data/library/cognos/page123.html
Title: Re: Change language (product and content) via a URL
Post by: Jiayue.lin on 02 Sep 2013 02:08:22 AM
Hi Michal,

may i know that  which you mean  to display in english/french, the UI or reports ?

Regards,
Lin
Title: Re: Change language (product and content) via a URL
Post by: michal on 03 Oct 2013 06:42:28 AM
Quote from: Jiayue.lin on 02 Sep 2013 02:08:22 AM
Hi Michal,

may i know that  which you mean  to display in english/french, the UI or reports ?

Regards,
Lin

sorry to ressurect this old post, just replying to Lin,

i am looking for a way to switch language with a URL link.

like :   FRENCH (http://french)  ENGLISH (http://english)

report, ui.  everything / anything possible.

hacked a bit on this but there doesnt seem to be any ways in the product to do this easily
pretty much HAVE to go to a 'my preferences' page.

kind of disappointed.  all in all :)



edit : we finally found a way to switch the language (or whatever 'my preferences' window has to offer in all its glory) with single link


http://your.cognos.place/BI/cgi-bin/cognosisapi.dll?ifrmcmd=save&m_return=&m_po_linesPerPage=99&m_po_listViewSeparator=background&p_style_back=&
m_po_skin=storeID%28%22i1313D0E244A2454FAD51753774F22902%22%29&
m_po_showHiddenObjects=false&m_p_format=HTML&m_po_showWelcomePage=false&m_po_showOptionSummary=true&runoptions=true&m_go_accessibilityFeatures=false&
m_po_displayMode=list&m_po_columnsPerPage=3&
m_select_productLocale=select&m_productLocale=fr&changed_m_p_productLocale=1&m_p_productLocale=fr&m_select_contentLocale=select&m_contentLocale=fr&changed_m_p_contentLocale=1&m_p_contentLocale=fr&
m_select_timeZoneID=default&changed_m_p_timeZoneID=0&m_p_timeZoneID=EST&encoding=UTF-8&b_action=xts.run&m_obj=%7E&m_class=account&
backURL=%2FBI%2Fcgi-bin%2Fcognosisapi.dll%3Fb_action%3DcognosViewer%26ui.action%3Drun%26ui.object%3D%252fcontent%252ffolder%255b%2540name%253d%2527BI%2520Landing%2520Page%2527%255d%252ffolder%255b%2540name%253d%2527Landing%2520Page%2520Reports%2527%255d%252ffolder%255b%2540name%253d%2527Navigation%2527%255d%252finteractiveReport%255b%2540name%253d%2527Navigation%2520Active%2520Report%2520w%2520ID%2520-G%2527%255d%26ui.name%3DNavigation%2520Active%2520Report%2520w%2520ID%2520-George%26run.outputFormat%3D%26run.prompt%3Dtrue&
m=portal%2Fsubmit.xts&ui.cafcontextid=CAFW00000070Q0FGQTNjMDAwMDAwMDlGQUFBQU1ENE5uQ0tBM2E5Rnp0M1YqaG5LWUtnMGd6cjRKWldOeWJSMTIxUkVvMU1XLXZTWjU0anpoTV8zODUwNDV8cHM_&ps_nav_op=submit&ps_nav_stack=&ps_nav_source=portal%2Fpreferences%2Fgeneral.xts


daunting perhaps, but it works ;)
if you just change the product/content locale settings to whatever you want (in my case, en/fr) it's as if you went to the preference page and saved the settings.

so, in all 3 things to check there.

1) m_po_skin should be set to whatever storeID you have for your default (or whatever) skin  (you can find out storeID in the administration page / configuration / styles / properties
2) content/product locale variables to whatever you need
3) backURL parameter set to wherever you want the link to go after you clicked it (in my case it's an active report landing page / home page for BI)

last, i am unsure if ui.cafcontextid changes for this from install to install, but i'm sure it must?
we captured the whole request with firebug/fiddler so it's easy to get - i am unsure how else to generate this, looks encoded or something but it worked on two different portals we have (dev/test here)

just thought i'd post a solution in case anyone else needs it.

Title: Re: Change language (product and content) via a URL
Post by: michal on 04 Dec 2013 12:57:10 PM
'modify' didnt bump the post :) so here goes

Title: Re: Change language (product and content) via a URL
Post by: CognosPaul on 05 Dec 2013 12:27:59 AM
Nice find, I'm really impressed! I tried to find that, but gave up at some point.

It looks like you don't need the entire string, a simple:
http://your.cognos.place/BI/cgi-bin/cognosisapi.dll?ifrmcmd=save
&ps_nav_op=submit
&changed_m_p_productLocale=1
&m_p_productLocale=fr
&m_select_contentLocale=select
&m_contentLocale=fr
&changed_m_p_contentLocale=1
&m_p_contentLocale=fr


(without the carriage returns) will switch the locales.

This brings up some very interesting possibilities. If we can control user preferences like this, then control of other forms should be possible too. There have been a few requests from people looking to trigger certain events without having to fill in a form.

Again, very well done!
Title: Re: Change language (product and content) via a URL
Post by: michal on 06 Dec 2013 08:41:23 AM
ooo, nicely shortened version mr Paul.  Thank you !
Title: Re: Change language (product and content) via a URL
Post by: CognosPaul on 10 Dec 2013 03:19:06 AM
Doing more digging. All you really need is

http://your.cognos.place/BI/cgi-bin/cognosisapi.dll?m_contentLocale=fr&m_productLocale=fr

Other attributes aren't normally supported. For example, http://your.cognos.place/BI/cgi-bin/cognosisapi.dll?m_po_linesPerPage=2 doesn't do anything. What's happening behind the scenes is that Cognos isn't actually changing the locale of the user. It's setting a cookie that will change the locale for that session. Logging off and on will revert the locale to whatever the user has set.

m_contentLocale and m_productLocale are actually hard coded into one of the template files in order to allow Cognos to accept and process the command.

<cognos Install>\templates\ps\portal\main.xts

By adding  or /root/env/param[@name = 'm_po_linesPerPage'] to the condition in the modifyLocales block and
<xsl:if test="/root/env/param[@name = 'm_po_linesPerPage']">
<item>
<name xsi:type="xsd:string">linesPerPage</name>
<value xsi:type="xsd:string">
<xsl:value-of select="/root/env/param[@name = 'm_po_linesPerPage']"/>
</value>
</item>
</xsl:if>

to the <bus:userPreferenceVars> node and removing portal.jar I was able to pass a linesPerPage amount for an individual session.