Fórum

Localization of Web Form Portlet

thumbnail
Gerfried Klein, modificado 16 Anos atrás.

Localization of Web Form Portlet

New Member Postagens: 8 Data de Entrada: 14/01/08 Postagens Recentes
Hi,

is there a way to define a localized Web Form?
I could not find any information about this in the wiki or the forum.
How would you implement a contact form if your site is multilingual?

thanx
Gerfried
thumbnail
Pablo Mosquera Sáenz, modificado 16 Anos atrás.

RE: Localization of Web Form Portlet

Junior Member Postagens: 61 Data de Entrada: 22/01/08 Postagens Recentes
I found a way to solve these problem

ext-web/docroot/portlet/web_form/view.jsp

I will show just an example of text and options

....

<c:when test='<%= fieldType.equals("text") %>'>
<table width="500px" class="ctrl-holder" border="0">
<tr height="40px">
<td width="80px"><label class='<%= fieldOptional ? "optional" : "" %>' for="<portlet:namespace /><%= fieldName %>"> &nbsp;<%= LanguageUtil.get(pageContext, Html.escape(fieldLabel)) %></label></td>
<td><input class='<%= fieldOptional ? "optional" : "" %>' id="&lt;portlet:namespace /&gt;<%= fieldName %>3" name="&lt;portlet:namespace /&gt;<%= fieldName %>3" type="text" value="<%= Html.escape(fieldValue) %>" />
</label></td>
</tr>
</table>

....

....

<c:when test='<%= fieldType.equals("options") %>'>
<div class="ctrl-holder <%= fieldOptional ? "optional" : "" %>">
<table border="0">
<tr>
<td height="38px"> <label class='<%= fieldOptional ? "optional" : "" %>' for="<portlet:namespace /><%= fieldName %>"><%= LanguageUtil.get(pageContext, Html.escape(fieldLabel)) %></label></td>

<td style="padding-left:38px" height="40px" ><%
String[] options = WebFormUtil.split(fieldOptions);
%>

<select name="<portlet:namespace /><%= fieldName %>">

<%
for (int j = 0; j < options.length; j++) {
String optionValue = options[j].trim();
%>

<option <%= fieldValue.equals(optionValue) ? "selected" : "" %> value="<%= Html.escape(optionValue) %>"><%= LanguageUtil.get(pageContext, Html.escape(optionValue)) %></option>

<%
}
%>

</select></td>
</tr>
</table>
</div>
</c:when>

.....



As you can see, I work with language tags instead of var names. When I define the web form I will put a field name that must be defined in the language-(ext).properties file.
thumbnail
Gerfried Klein, modificado 16 Anos atrás.

RE: Localization of Web Form Portlet

New Member Postagens: 8 Data de Entrada: 14/01/08 Postagens Recentes
Hi,

this seems to be useful or us.
In my opinion there should be a check:
if a value in the language configuration is present, use this value, otherwise use the field name itself.
This change would be compatible the the original version and this could be supplied as patch to the trunk.

in the meantime i will try this solution.
thanks
Gerfried
thumbnail
Pablo Mosquera Sáenz, modificado 16 Anos atrás.

RE: Localization of Web Form Portlet

Junior Member Postagens: 61 Data de Entrada: 22/01/08 Postagens Recentes
Ok, there is something wrong in the code I posted

Change

"&lt;portlet:namespace /&gt;<%= fieldName %>3"

with

"<portlet:namespace />;<%= fieldName %>"


About the check, liferay prints the tag if there is no translation in the language files, so you can still use the webform in the old way
thumbnail
Marcus Souza, modificado 14 Anos atrás.

RE: Localization of Web Form Portlet

Junior Member Postagens: 58 Data de Entrada: 31/03/09 Postagens Recentes
Hi,

i used your way to do the localization in the web-form-portlet and it works fine. The Localization is only for the Portlet... and in the Emailbody will appear the key(not the value of the key) from the language_properties... I went to the class WebFormPortlet and changed

	protected String getMailBody(Map<string,string> fieldsMap) {
		StringBuilder sb = new StringBuilder();

		for (String fieldLabel : fieldsMap.keySet()) {
			String fieldValue = fieldsMap.get(fieldLabel);
				Locale pageContext = null;
				[b]// sb.append(fieldLabel);
				sb.append(LanguageUtil.get(pageContext, HtmlUtil.escape(fieldLabel)));[/b]
				sb.append(" : ");
				sb.append(fieldValue);
				sb.append("\n");
		}
</string,string>


The Problem is that i need the pagecontext variable and i dont know where it's created... I dont know from where the view.jsp use it
thank you in advance,

EDIT: i found it already thanks anyway

actionRequest.getLocale()

Marcus Souza
thumbnail
Ezequiel Chavez, modificado 16 Anos atrás.

RE: Localization of Web Form Portlet

Regular Member Postagens: 135 Data de Entrada: 20/01/06 Postagens Recentes
Gerfried Klein:
This change would be compatible the the original version and this could be supplied as patch to the trunk.


Hi

In my opinion looks like a good solution, but temporary, because it involves editing the file Language-ext.properties, I have to know in advance which web forms going to create on the portal, must restart the server after creating web forms on demand for any particular need and modify Languagel-ext.properties. That does not seems to me a robust solution, it would be best multi-language support from portlet configuration screen.

Regards.
thumbnail
Gerfried Klein, modificado 16 Anos atrás.

RE: Localization of Web Form Portlet

New Member Postagens: 8 Data de Entrada: 14/01/08 Postagens Recentes
thats right, I would like to have a full multi lingual web form, too, but its reasonable workaround.
thanx
thumbnail
Pablo Mosquera Sáenz, modificado 16 Anos atrás.

RE: Localization of Web Form Portlet

Junior Member Postagens: 61 Data de Entrada: 22/01/08 Postagens Recentes
Hi Ezequiel, its not a final solution but the effort to do this solution is very few, and if you want to have a truly multi-lingual webform portlet it would take more time to implement it. I used this solution because I have no time to implement the multi-lingual portlet, and the portal admins will not add new webform portlets.

Anyway, I have reported the solution to the liferay support web.
thumbnail
Ezequiel Chavez, modificado 16 Anos atrás.

RE: Localization of Web Form Portlet

Regular Member Postagens: 135 Data de Entrada: 20/01/06 Postagens Recentes
Totally agree, in many cases your solution is enough.

Meanwhile, since you use the web form Portlet, can enrich the idea put forward here?

Regards.