Impact of the 'locales.enabled' property on Instance Settings language configuration

Issue

  • There is a portal property to specify the locales that are enabled by default: locales.enabled.
  • However you can change that from Control Panel > Instance Settings > Localization.
  • How that portal property and that instance setting interact with each other?

Environment

  • Liferay DXP 7.3

Resolution

  • Liferay leverages the property value until it's overwritten by the instance setting. Once a change is made, it's persisted in the database and subsequent access to the language selection panel will be determined by the database value.
  • To determine enabled locales, PrefsPropsUtil is invoked to retrieve the corresponding preference from the database. If no preference is found, the default value specified in the locales.enabled property is used as a fallback. See language.jsp#L74-L96:
    • String[] currentLanguageIds = PrefsPropsUtil.getStringArray(
      company.getCompanyId(), PropsKeys.LOCALES, StringPool.COMMA, PropsValues.LOCALES_ENABLED);
      where PropsKeys.LOCALES is the preference key (i.e., the instance setting's name) and PropsValues.LOCALES_ENABLED is the default value (i.e., the value from the locales.enabled property) returned when no database record is found.
  • Also, as you can see in the above snippet, the approach is slightly different for 'available' locales. The code directly accesses the locales property and the retrieved value is then processed accordingly.

Additional Information

この記事は役に立ちましたか?
0人中0人がこの記事が役に立ったと言っています