Foros de discusión
Localization of Web Form Portlet
Gerfried Klein, modificado hace 16 años.
Localization of Web Form Portlet
New Member Mensajes: 8 Fecha de incorporación: 14/01/08 Mensajes recientes
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
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
Pablo Mosquera Sáenz, modificado hace 16 años.
RE: Localization of Web Form Portlet
Junior Member Mensajes: 61 Fecha de incorporación: 22/01/08 Mensajes recientes
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 %>"> <%= LanguageUtil.get(pageContext, Html.escape(fieldLabel)) %></label></td>
<td><input class='<%= fieldOptional ? "optional" : "" %>' id="<portlet:namespace /><%= fieldName %>3" name="<portlet:namespace /><%= 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.
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 %>"> <%= LanguageUtil.get(pageContext, Html.escape(fieldLabel)) %></label></td>
<td><input class='<%= fieldOptional ? "optional" : "" %>' id="<portlet:namespace /><%= fieldName %>3" name="<portlet:namespace /><%= 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.
Gerfried Klein, modificado hace 16 años.
RE: Localization of Web Form Portlet
New Member Mensajes: 8 Fecha de incorporación: 14/01/08 Mensajes recientes
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
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
Pablo Mosquera Sáenz, modificado hace 16 años.
RE: Localization of Web Form Portlet
Junior Member Mensajes: 61 Fecha de incorporación: 22/01/08 Mensajes recientes
Ok, there is something wrong in the code I posted
Change
"<portlet:namespace /><%= 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
Change
"<portlet:namespace /><%= 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
Marcus Souza, modificado hace 14 años.
RE: Localization of Web Form Portlet
Junior Member Mensajes: 58 Fecha de incorporación: 31/03/09 Mensajes recientes
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
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
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
Ezequiel Chavez, modificado hace 16 años.
RE: Localization of Web Form Portlet
Regular Member Mensajes: 135 Fecha de incorporación: 20/01/06 Mensajes recientesGerfried 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.
Gerfried Klein, modificado hace 16 años.
RE: Localization of Web Form Portlet
New Member Mensajes: 8 Fecha de incorporación: 14/01/08 Mensajes recientes
thats right, I would like to have a full multi lingual web form, too, but its reasonable workaround.
thanx
thanx
Pablo Mosquera Sáenz, modificado hace 16 años.
RE: Localization of Web Form Portlet
Junior Member Mensajes: 61 Fecha de incorporación: 22/01/08 Mensajes recientes
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.
Anyway, I have reported the solution to the liferay support web.
Ezequiel Chavez, modificado hace 16 años.
RE: Localization of Web Form Portlet
Regular Member Mensajes: 135 Fecha de incorporación: 20/01/06 Mensajes recientes
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.
Meanwhile, since you use the web form Portlet, can enrich the idea put forward here?
Regards.