on 06-23-2005 8:09 AM
Hi everybody,
I have to implement internationalization in my Portal.
I do it throws bundle resources in my iview and throws Portal Content Translation for workset name.
But now, I need to implement a iview in which there are 3 flag (english, french and german for example) and when a user clicks on one of these, this changes the Portal language.
Do someone know how I can do that?
I think I have to change the locale of the session on the button clic but I don't find how to di that ..
Thanks,
Fabien
Hi Faben!
I think what u can do is put a MessageResourceBundle.properties file in your src.core
That properties file will be like
NewsEN = English News
NewsFR = French News
NewsGR = German News
Create an application ie either abstract portal component where you can use following syntax
if (language.equals("EN")) response.write(MessageResourceBundle.getString("newsEN"));
and so on for french and german.
Also while loading the page u ve to take care of Language otherwise it will return null pointer exception
so for that following syntax should be added
if (request.getParameter("lanselected") == null)
lanselected = EN;
to toggle in the language u can use java script function onClick... and change the value of lanselected there.
You can deploy this.
And create an iView for that par file
Hope it works and u got it...
Regards
Anish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
> if (language.equals("EN"))
>
> response.write(MessageResourceBundle.getString("newsE
> N"));
> and so on for french and german.
>
Anish, this is done automatically based on the user's locale! No "if" needed...
Fabien, I haven't done it yet, but maybe it's the best to implement a function that changes the user's locale.
The locale lookup rules of the portal are the following:
http://help.sap.com/saphelp_nw04/helpdata/en/ce/b31e40777cdd5fe10000000a155106/frameset.htm
Regards, Karsten
Hi Karsten!
Hey i used "if(language.equals("EN"))" coz some times there is the need to implement all the languages say English, german, etc... in a single iView so that a user on clicking the language toggle can change the language.
So by this irrespective of the locality of the user, he/she can look the content in all the languages provided in the toggle.
regards,
Anish
> Hey i used "if(language.equals("EN"))" coz some times
> there is the need to implement all the languages say
> English, german, etc...
Of course it is, this is the whole sense of a ResourceBundle...
http://java.sun.com/j2se/1.4.2/docs/api/java/util/ResourceBundle.html
In portal components it's even simpler, just declare the bundle in the portalapp.xml and read strings as described here:
http://help.sap.com/saphelp_nw04/helpdata/en/97/cd1e400191f72ee10000000a1550b0/frameset.htm
What Fabien needs, is a component placed on the framework page that changes the user's locale.
This is an example coding to change the language to french:
public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
{
try {
IUserMaint mutableUser = userFactory.getMutableUser(request.getUser().getUniqueID());
mutableUser.setLocale(Locale.FRENCH);
mutableUser.commit();
} catch (UMException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Regards, Karsten
Hi,
Your response are all helpfull ..
I need to change language of wole Portal (iviews, workset name, page name ...) when user select a flag language.
I want to simulate the fact that user go on IE option and change the language: all Portal text is changed..
So I thinks that the best way to do this is Karsten one.
In this way, I will try it ...
I will give you a feedback
Thanks,
Fabien
Hi Karsten,
What you have said is right.
I change the user's locale.
So next time the user re-logg to the Portal, he will keep this locale...
Is there a way to change 'temporally' this locale ?
That means not to change the user's locale but the session locale for example.
This means that local change is applied only for the current session ...
Regards,
Fabien
Hi Karsten,
The point that make me wondering if a sesion locale was existing is the enxt one :
When a user changes the locale and logs out, next time he loggons, he will keep this locale. (the new one)
So he doesn't arrive on th default one ..
But user's locale is responding to my problem too, so it is good ..
Regards,
Fabien
Fabien,
How do you change your Portal contents to French?
I can understand how you changed your Iviews tabs to French, but if your Portal contents (text) are in English how does that change to French?
I am in the same situation and I will really appriciate if you can provide me the steps that you did to have this implemented.
this is my e-mail address: kurien.baby@ottawa.ca
Thanks
-Kurien
Hi Kurien,
All Portal traduction is made with the "Portal Content Translation" under "Content Administration".
Here you define all workset, page, iview you want to translate.
Then when I developp iView (JSDynpage & htmlb), I use bundle resources.
And to change language dynamically , I use :
IUserFactory userFactory = UMFactory.getUserFactory();
IUserMaint user = userFactory.getMutableUser((request.getUser().getUniqueID()));
user.setLocale(Locale.ENGLISH);
user.commit();
And so, all is translate: navigation + content
Regards,
Fabien
I am in a similar situation where the Portal language needs to be toggled in a custom iView. I have implemented the change using the getLocale/setLocale as well as the save() and commit() methods of the IUser object.
Does anyone now know how to force the portal session to refresh, similar to what happens when the user selects "Save" in the standard Personalization iView? This would prevent the user from having to manually refresh their browser window for the new language to take effect.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Guys
Just so you know we have implemented this type of functionality. If you use the localization link in the header of SDN and change to another language it will temporarily change the language of the user in the session. Then, if you log back in to SDN, it will use the language that as been persisted. Give it a try, works really well.
This has been implement by using a J2EE server filter. The J2EE server filter basically implements the Filter class. You can then create a wrapper class that encapsulates the the HttpServletRequest. In your wrapper class you can create a method that returns any form of Locale. You can then set the Locale in the response (HttpServletResponse). This new Locale will then be set for the IPortalComponentRequest.getLocale() method.
I hope this helps a little
D
I hope this makes some kind of sense
Hi Faben!
I think what u can do is put a MessageResourceBundle.properties file in your src.core
That properties file will be like
NewsEN = English News
NewsFR = French News
NewsGR = German News
Create an application ie either abstract portal component where you can use following syntax
if (language.equals("EN")) response.write(MessageResourceBundle.getString("newsEN"));
and so on for french and german.
Also while loading the page u ve to take care of Language otherwise it will return null pointer exception
so for that following syntax should be added
if (request.getParameter("lanselected") == null)
lanselected = EN;
to toggle in the language u can use java script function onClick... and change the value of lanselected there.
You can deploy this.
And create an iView for that par file
Hope it works and u got it...
Regards
Anish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
75 | |
9 | |
8 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.