Skip to content

Commit

Permalink
LPS-26840 Consolidate logic
Browse files Browse the repository at this point in the history
  • Loading branch information
brianchandotcom committed Apr 20, 2012
1 parent 35be891 commit e9159ac
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 13 deletions.
10 changes: 10 additions & 0 deletions portal-impl/src/com/liferay/portal/model/impl/CountryImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@

package com.liferay.portal.model.impl;

import com.liferay.portal.kernel.language.LanguageUtil;
import com.liferay.portal.model.CountryConstants;

import java.util.Locale;

/**
* @author Brian Wing Shun Chan
*/
Expand All @@ -22,4 +27,9 @@ public class CountryImpl extends CountryBaseImpl {
public CountryImpl() {
}

public String getName(Locale locale) {
return LanguageUtil.get(
locale, CountryConstants.NAME_PREFIX + getName());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -1054,8 +1054,7 @@ protected List<String> getLocalizedCountryNames(Country country) {
Locale[] locales = LanguageUtil.getAvailableLocales();

for (Locale locale : locales) {
String countryName = LanguageUtil.get(
locale, "country." + country.getName());
String countryName = country.getName(locale);

countryName = countryName.toLowerCase();

Expand Down
1 change: 1 addition & 0 deletions portal-service/src/com/liferay/portal/model/Country.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ public interface Country extends CountryModel {
*
* Never modify this interface directly. Add methods to {@link com.liferay.portal.model.impl.CountryImpl} and rerun ServiceBuilder to automatically copy the method declarations to this interface.
*/
public java.lang.String getName(java.util.Locale locale);
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ public class CountryConstants {
PropsUtil.get(
PropsKeys.SQL_DATA_COM_LIFERAY_PORTAL_MODEL_COUNTRY_COUNTRY_ID));

public static final String NAME_PREFIX = "country.";

}
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ public java.lang.String toXmlString() {
return _country.toXmlString();
}

public java.lang.String getName(java.util.Locale locale) {
return _country.getName(locale);
}

/**
* @deprecated Renamed to {@link #getWrappedModel}
*/
Expand Down
7 changes: 2 additions & 5 deletions portal-service/src/com/liferay/portlet/UserAttributes.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.language.LanguageUtil;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.StringPool;
Expand Down Expand Up @@ -492,8 +491,7 @@ else if (name.equals(USER_HOME_INFO_POSTAL_COUNTRY)) {
if (_personalAddress != null) {
Country country = _personalAddress.getCountry();

return LanguageUtil.get(
_user.getLocale(), "country." + country.getName());
return country.getName(_user.getLocale());
}

return StringPool.BLANK;
Expand Down Expand Up @@ -636,8 +634,7 @@ else if (name.equals(USER_BUSINESS_INFO_POSTAL_COUNTRY)) {
if (_businessAddress != null) {
Country country = _businessAddress.getCountry();

return LanguageUtil.get(
_user.getLocale(), "country." + country.getName());
return country.getName(_user.getLocale());
}

return StringPool.BLANK;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ if (displayTerms.getParentOrganizationId() > 0) {
selectDesc: 'name',
selectId: 'countryId',
selectLocalizeDesc: '<%= true %>',
selectLocalizeDescPrefix: '<%= "country." %>',
selectLocalizeDescPrefix: '<%= CountryConstants.NAME_PREFIX %>',
selectSort: '<%= true %>',
selectVal: '<%= displayTerms.getCountryId() %>'
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ else {
selectData: Liferay.Address.getCountries,
selectDesc: 'name',
selectLocalizeDesc: '<%= true %>',
selectLocalizeDescPrefix: '<%= "country." %>',
selectLocalizeDescPrefix: '<%= CountryConstants.NAME_PREFIX %>',
selectSort: '<%= true %>',
selectId: 'countryId',
selectVal: '<%= countryId %>'
Expand Down Expand Up @@ -176,7 +176,7 @@ else {
selectData: Liferay.Address.getCountries,
selectDesc: 'name',
selectLocalizeDesc: '<%= true %>',
selectLocalizeDescPrefix: '<%= "country." %>',
selectLocalizeDescPrefix: '<%= CountryConstants.NAME_PREFIX %>',
selectSort: '<%= true %>',
selectId: 'countryId',
selectVal: ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ if (parentOrganization != null) {
selectData: Liferay.Address.getCountries,
selectDesc: 'name',
selectLocalizeDesc: '<%= true %>',
selectLocalizeDescPrefix: '<%= "country." %>',
selectLocalizeDescPrefix: '<%= CountryConstants.NAME_PREFIX %>',
selectSort: '<%= true %>',
selectId: 'countryId',
selectVal: '<%= countryId %>'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ if (displayTerms.getParentOrganizationId() > 0) {
selectData: Liferay.Address.getCountries,
selectDesc: 'name',
selectLocalizeDesc: '<%= true %>',
selectLocalizeDescPrefix: '<%= "country." %>',
selectLocalizeDescPrefix: '<%= CountryConstants.NAME_PREFIX %>',
selectSort: '<%= true %>',
selectId: 'countryId',
selectVal: '<%= displayTerms.getCountryId() %>'
Expand Down
2 changes: 1 addition & 1 deletion portal-web/docroot/html/taglib/ui/write/page.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ String property = (String)request.getAttribute("liferay-ui:write:property");
try {
country = CountryServiceUtil.getCountry(organization.getCountryId());
countryName = LanguageUtil.get(pageContext, "country." + country.getName());
countryName = country.getName(locale);
}
catch (Exception e) {
}
Expand Down

0 comments on commit e9159ac

Please sign in to comment.