フォーラム

ホーム » Liferay Portal » English » 3. Development

構造的に表示 平面上に表示 ツリー上に表示
スレッド [ 前へ | 次へ ]
toggle
Manish Kumar Jaiswal
Setting Preferred Language
2012/09/07 5:49
答え

Manish Kumar Jaiswal

ランク: Regular Member

投稿: 133

参加年月日: 2008/11/25

最近の投稿

How to set preferred Language of the user from a new plugin portlet .(setting the language as the preference to use the portal)

Regards
Manish
Vitaliy Koshelenko
RE: Setting Preferred Language
2012/09/07 12:31
答え

Vitaliy Koshelenko

ランク: Regular Member

投稿: 237

参加年月日: 2011/03/25

最近の投稿

Hi! You can just change languageId for user, for example:

1user.setLanguageId(languageId);


Vitaliy
Manish Kumar Jaiswal
RE: Setting Preferred Language
2012/09/07 12:34
答え

Manish Kumar Jaiswal

ランク: Regular Member

投稿: 133

参加年月日: 2008/11/25

最近の投稿

Thanks Vitaliy

will this also allow the user to see all the content into that particular language when he/she logins ?

Regards
Manish
Vitaliy Koshelenko
RE: Setting Preferred Language
2012/09/07 12:36
答え

Vitaliy Koshelenko

ランク: Regular Member

投稿: 237

参加年月日: 2011/03/25

最近の投稿

Yes, user will see the portal in that particular language.
Hitoshi Ozawa
RE: Setting Preferred Language
2012/09/08 8:23
答え

Hitoshi Ozawa

ランク: Liferay Legend

投稿: 7952

参加年月日: 2010/03/23

最近の投稿

May have to do the following

PortletPreferences prefs = request.getPreferences();
prefs.setValue(...);
PortletPreferencesLocalServiceUtil.updatePreferences(prefs);
Manish Kumar Jaiswal
RE: Setting Preferred Language
2012/09/08 8:29
答え

Manish Kumar Jaiswal

ランク: Regular Member

投稿: 133

参加年月日: 2008/11/25

最近の投稿

In portlet preferences we use to save like this
example
prefs.setValue("node-id", Long.toString(node.getNodeId()));

so i understand we will put languageid but wat will be the key is it languageId ?

T&R
Manish
Manish Kumar Jaiswal
RE: Setting Preferred Language
2012/09/10 1:30
答え

Manish Kumar Jaiswal

ランク: Regular Member

投稿: 133

参加年月日: 2008/11/25

最近の投稿

Vitaliy ,
It saves the language of the user and when he logins next time it shows him/her that language but within the same session he doesnt see the language changed is it we need to do something else ?

Regards
Manish
Vitaliy Koshelenko
RE: Setting Preferred Language
2012/09/10 12:33
答え

Vitaliy Koshelenko

ランク: Regular Member

投稿: 237

参加年月日: 2011/03/25

最近の投稿

You can change the language for current user's session like this:

1Locale locale = LocaleUtil.fromLanguageId(languageId);
2session.setAttribute(org.apache.struts.Globals.LOCALE_KEY, locale);
Hitoshi Ozawa
RE: Setting Preferred Language
2012/09/11 4:36
答え

Hitoshi Ozawa

ランク: Liferay Legend

投稿: 7952

参加年月日: 2010/03/23

最近の投稿

Vitaliy, thank you for the reply but the question is setting another users language from a portlet and not the current user.
MICHAIL MOUDATSOS
RE: Setting Preferred Language
2012/09/11 5:20
答え

MICHAIL MOUDATSOS

ランク: Regular Member

投稿: 110

参加年月日: 2011/10/04

最近の投稿

Vitaliy Koshelenko:
You can change the language for current user's session like this:

1Locale locale = LocaleUtil.fromLanguageId(languageId);
2session.setAttribute(org.apache.struts.Globals.LOCALE_KEY, locale);

Hitoshi Ozawa:
Vitaliy, thank you for the reply but the question is setting another users language from a portlet and not the current user.


Then, in order to use Vitaliy's way, you should keep track of user sessions. It is feasible but i don't know if it worths to maintain all that info just to have the ability to change a user's default language on the fly.