Fórumok

Portlet title localization

Gustavo Fernandes, módosítva 11 év-val korábban

Portlet title localization

Junior Member Bejegyzések: 25 Csatlakozás dátuma: 2011.10.03. Legújabb bejegyzések
Hello,

I am trying to make a portlet title localizable.
So, i followed the instructions to do so. Namely, this and this.

Yes the portlet title gets localized BUT..... if the portlet title contains accented characters (portuguese in my case) these characters are rendered as "gibberish", for the portlet title. The remaining bundle labels are not affected.
Example, for a portuguese word: Gestão, which gets rendered as : Gest�o

IF i modify the resource bundle file's encoding. In this case the title gets rendered correctly BUT.... the other bundle labels, which contain accented characters, are rendered incorrectly.

I atttached the resource bundle files, and the portlet.xml file.

I have this version of liferay bundle, over JBOSS using MySQL :

Liferay Portal Community Edition 6.1.1 CE GA2 (Paton / Build 6101 / July 31, 2012

I am developing using Eclipse Indigo.

The prescribed way (the 'official' one) does not work for these characters.

Any suggestions?

Thank you for any thoughts you might have.

Cheers,

Gustavo
Gustavo Fernandes, módosítva 11 év-val korábban

RE: Portlet title localization

Junior Member Bejegyzések: 25 Csatlakozás dátuma: 2011.10.03. Legújabb bejegyzések
Just dropping a line on what was the solution i and a colleague found.
We found it on stackoverflow, but i don't have the link right now.

So we have changed the encoding for the resource bundle files (.properties) to UTF-8.
Then, inside the functions we're using to get the bundle values;

public static String getValue(String key, String valueForKeyNotFound ){
		String keyNotfoundMessage = bundle.getString(WebContentListPortletConstants.MESSAGE_KEYNOTFOUND);
		String value=keyNotfoundMessage+key;		
		try {
			value = bundle.getString(key);
		} catch (MissingResourceException ex){
			if(valueForKeyNotFound != null && !valueForKeyNotFound.isEmpty() ){
				value = valueForKeyNotFound;
			}
		}		
		try {
			[b]value =  new String(value.getBytes("ISO-8859-1"), "UTF-8");[/b]
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return value;
		
	}


Not a very ellegant solution, rather a workaround, i know.
HTH someone out there!

Gustavo