cancel
Showing results for 
Search instead for 
Did you mean: 

Get the language of portal

Former Member
0 Kudos

Hi,

I would like to know which language use the user.

How can I get this?

I want to implement it in 'umLogonPage.jsp'.

I would like to put out some language dependent pictures to the login page.

Something like this (in JAVA):


<%
    java.util.Locale locale = (Locale)session.getAttribute("locale");
    if (locale.getLanguage().equals("en")) 
    { 
%>		
        img src="<%=webpath%>layout/EN/login_pic.jpg" border="0" align="top"
<% 
    }
    else if (locale.getLanguage().equals("sk")) 
    { 
%>
        <img src="<%=webpath%>layout/SK/login_pic.jpg" border="0" align="top"
<% 
    }

thanks,

bejglee

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Thank you very much everybody!

I'm going to use these recommendations!

I created a temporary solution:

- I picked up two property:


  // languages_en.properties
  LANG=en
  IMG_MSG=Go to page...

  // languages_sk.properties
  LANG=sk
  IMG_MSG=Prejs na str\u00E1nku...

in the 'umLogonPage.jsp':


<%
  String lang_dir = "";
  String img_msg = "";
  try 
  {
    lang_dir = logonLocale.get("LANG");
    img_msg = logonLocale.get("IMG_MSG");
  }
  catch (Exception e)
  {
    lang_dir = "en";
    img_msg = "Go to page'...";
  }
%>
...
<!-- html code
<a target="_blank" href="http://{URL}"
img src="<%=webpath%>layout/images/<%=lang_dir%>/img.jpg" alt="<%=img_msg%>" border="0" align="center"></a>
-->

thanks,

bejglee

former_member218672
Active Contributor
0 Kudos

Hi,

You can extract language from ume by using below code -

String language = umUser.getAttribute("com.sap.security.core.usermanagement", "Language") where umUser is IUser object

You can extract language from local by below code -

language = request.getParameter("ume.logon.locale")

Even you can extract language from cookie.

Cheers,

Sen

Former Member
0 Kudos

>

> Hi,

> I would like to know which language use the user.

> How can I get this?

> I want to implement it in 'umLogonPage.jsp'.

> I would like to put out some language dependent pictures to the login page.

> Something like this (in JAVA):

>


> <%
>     java.util.Locale locale = (Locale)session.getAttribute("locale");
>     if (locale.getLanguage().equals("en")) 
>     { 
> %>		
>         img src="<%=webpath%>layout/EN/login_pic.jpg" border="0" align="top"
> <% 
>     }
>     else if (locale.getLanguage().equals("sk")) 
>     { 
> %>
>         <img src="<%=webpath%>layout/SK/login_pic.jpg" border="0" align="top"
> <% 
>     }
> 

> thanks,

> bejglee

Hi bejglee,

You can simply use IPortalComponentRequest's method getLocale to get the current language of the user:

[http://help.sap.com/javadocs/NW04/current/ep/com/sapportals/portal/prt/component/IPortalComponentRequest.html#getLocale()|http://help.sap.com/javadocs/NW04/current/ep/com/sapportals/portal/prt/component/IPortalComponentRequest.html#getLocale()]

If you are in JSP code, you can access this object like this:

<% Locale locale = componentRequest.getLocale(); %>

"componentRequest" is an implicit object and therefore always available.

This works for both named users (the locale is determined from UME) and anonymous users (the locale is determined from browser).

Former Member
0 Kudos

Hi ,

Have a look at the below links.

/message/4749439#4749439 [original link is broken]

Thanks,

Sandip