Change the default language in Liferay - liferay

How to change the default for language?
When a user logs in for the first time, the default language is English, and I need to change that.

You can change default language from Control panel - Portal Settings - Display Settings - Default langiuage.
Also you can override params at portal-ext.properties :
#
# Set the default locale used by Liferay. This locale is no longer set at
# the VM level. See LEP-2584.
#
user.country=US
user.language=en
BR,
Paul

From Liferay 7 (released in 2016), the default language setting can be found in the UI at:
Control Panel > Instance Settings > Miscellaneous > Display Settings
Don't forget to press "Save" at the bottom of the page.
As MDT said, it overrides whatever is in portal-ext.properties.

Related

Freemarker does not assign staticUtil

I worked Application Display Templates on liferay 6.2, I use freemarker help pagination the dynamics data list of liferay. When I upgrade to liferay 7, it is a problem. Liferay 7 use code <#assign records = ddlDisplayTemplateHelper.getRecords(reserved_record_set_id)> for get a records.
Old code:
<#assign DDLRecordLocalService = serviceLocator.findService("com.liferay.portlet.dynamicdatalists.service.DDLRecordLocalService")>
<#assign records = DDLRecordLocalService.getRecords(reserved_record_set_id)>
<#assign totalRecord = DDLRecordLocalService.getRecordsCount(reserved_record_set_id, 0) >
It doesn't work.
So I try <#assign serviceLocator = staticUtil["com.liferay.portal.template.ServiceLocator"]> but staticUtil get an error.
The following has evaluated to null or missing:
==> staticUtil [in template "20115#20159#21387" at line 9, column 27]
Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing
In portal-ext.properties I have added:
freemarker.engine.restricted.classes=
freemarker.engine.restricted.packages=
freemarker.engine.restricted.variables=
The properties you refer to have been moved to an OSGI config in Liferay 7/DXP.
To deploy them you need to create a file named com.liferay.portal.template.freemarker.configuration.FreeMarkerEngineConfiguration.cfg and place it under $LIFERAY_HOME/osgi/configs
The content of the file will be the following:
restrictedVariables=
To find all the configs and their defaults you can have a look at the class com.liferay.portal.template.freemarker.configuration.FreeMarkerEngineConfiguration
That you can find in the Liferay source code.
I think those properties in portal-ext.properties are just ignored in liferay 7.
You can admin those properties in Control Panel → Configuration → System Settings → Foundation → FreeMarker Engine and remove "staticUtil" (or remove "serviceLocator" directly) from restricted variables. (liferay reboot is required)
Go to Control Panel -> System Settings -> Foundation Page
Find FreeMarker Engine from list click on it .
Remove serviceLocator variable and staticUtil from restricted variables by Clicking on (-) icon.
If you want to use staticUtil object then also remove this variable from restricted variables.
Save it.
Restart Liferay server.
You will direct access to serviceLocator object in your Application Display Template.
In liferay 7.1. you will find Freemaker Engine under
Control Panel -> System Settings -> Platform -> Template Engines
In liferay-ce-portal-7.1.1.2-ga3 version, the file is renamed to
com.liferay.portal.template.freemarker.configuration.FreeMarkerEngineConfiguration.config

How to disable liferay control panel's file upload size limit

In Liferay, under Control Panel -> Server Administration, we can set the file size upload limit. This overrides the
dl.file.max.size
setting in portal-ext. Can I disable the control panel from overriding this property?
Cause I want to use a seperate instance that has no upload size limit. If I'm not wrong the setting in the control panel applies to all instances connected to the same database.
We can find the setting in the liferay database table
select * from [liferay].[dbo].[PortalPreferences] where preferences like '%dl.file.max.size%';
We will get something like below:
<portlet-preferences>
.....
<preference>
<name>dl.file.max.size</name>
<value>104857600</value>
</preference>
<preference>
<name>com.liferay.portal.upload.UploadServletRequestImpl.max.size</name>
<value>524288000</value>
</preference>
.......
</portlet-preferences>
We just remove the above 2 preferences and we can set them in portal-ext.properties instead.

Liferay Language switch issue

I am trying to implement multiple language support in my liferay Project. For this i added below code in portal_normal.vmfile of theme.
#set( $availLanguage = $stringUtil.split("hi_IN,en_US"))
<span id="language">$taglibLiferay.language("fm", null, "languageId", $toto, 0)</span>
which will add support for two language Hindi,English (United States).
and created hook for multiple language properties files.
<hook>
<language-properties>content/Language_hi.properties</language-properties>
<language-properties>content/Language_en.properties</language-properties>
</hook>
but whenever i switch my language its not changing.It always shows values from Language_en.properties file
so to check whats happening i tried printing below values in theme
$theme_display.getLanguageId()
$locale
but it always shows en_US even thought i changed language to hi_IN.
Looking for help to figure out whats going wrong.
Environment: Liferay 6.1.1 CE GA2
I think you need to add hi_IN language as Available Languages in Portal Settings if it is already not there.
To add this/or verify go to Control Panel --> Portal Settings --> Display Settings
here you will find a input box Available Languages which shows all available locales (comma seperated), make sure you have entry for hi_IN in this input box.

How to change the Language of portlet's title?

I am trying to change the language of portlet title, but didn't succeed!
I went through the various link from liferay's forum, but unable to achieve my task.
Example:1
Example:2
Details:
I am using following locales fr_FR and zh_CN,with the following values in the concerned properties file
javax.portlet.title.1_WAR_microblogsportlet=News
javax.portlet.title.1_WAR_microblogsportlet=nouvelles(for fr_FR)
javax.portlet.title.1_WAR_microblogsportlet=新聞(for zh_CN)
resource bundle is set in portlet.xml as given:
<portlet-name>1</portlet-name>
<display-name>Microblogs</display-name>
<portlet-class>com.liferay.microblogs.microblogs.portlet.MicroblogsPortlet</por‌​tlet-class>
<resource-bundle>content.Language</resource-bundle>
You just need to have property with key as "javax.portlet.title", no need to put your portlet ID as part of key.
Name the localized properties files and put property value as below.
Language.properties
javax.portlet.title=News
Language_fr.properties
javax.portlet.title=nouvelles
Language_zh.properties
javax.portlet.title=新聞
Then liferay displays portlet in corresponding language depending on user's locale.
You may test in one of below ways.
For User -
In current user profile -> Display Settings, Select language as French and then visit the page having your portlet. It should display title in french instead of english.
Change in URL
You may also specify locale in page URL as described in liferay 6.1 documentation
http://localhost:8080/fr/<your page url>
Using Language portlet
Add Language portlet on your page and clicking on French flag changes locale to french and the page should display portlet title in French.

Set portlet as highlighted on add application panel

Liferay 6.2 CE
How exactly can one go about to set a portlet to show up on the highlighted category on the add application panel? I've been searching for hours, without any luck.
Have tried to define category name as "Highlighted", but it just creates a new one with the same name.
The main goal is just to have my own portlets sit on the top of the rest.
Cheers.
Configure the following settings (here with the defaults) in your portal-ext.properties:
##
## Dockbar Portlet
##
#
# Set the portlet ids that will be shown directly in the "Add Application"
# menu.
#
dockbar.add.portlets=56,101,110,71
Here you see that Liferay has the habit of numbering all the core portlets. Your own portlets ids will be constructed from their plugin name and the portlet id, e.g. the AmazingApp portlet that is deployed in the webapplication my-great-custom-plugins-portlet will have an ID of *amazingapp_WAR_mygreatcustompluginsportlet* (or similar). How can you find this out by yourself? Add it to the page, then choose "Look and Feel" and "Advanced Styling" - this will show the HTML id for your portlet, of which you can easily extract the actual portlet ID to use for portal-ext.properties.

Resources