掲示板

Localization of Web Form Portlet

thumbnail
16年前 に Gerfried Klein によって更新されました。

Localization of Web Form Portlet

New Member 投稿: 8 参加年月日: 08/01/14 最新の投稿
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
16年前 に Pablo Mosquera Sáenz によって更新されました。

RE: Localization of Web Form Portlet

Junior Member 投稿: 61 参加年月日: 08/01/22 最新の投稿
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
16年前 に Gerfried Klein によって更新されました。

RE: Localization of Web Form Portlet

New Member 投稿: 8 参加年月日: 08/01/14 最新の投稿
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
16年前 に Pablo Mosquera Sáenz によって更新されました。

RE: Localization of Web Form Portlet

Junior Member 投稿: 61 参加年月日: 08/01/22 最新の投稿
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
14年前 に Marcus Souza によって更新されました。

RE: Localization of Web Form Portlet

Junior Member 投稿: 58 参加年月日: 09/03/31 最新の投稿
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
16年前 に Ezequiel Chavez によって更新されました。

RE: Localization of Web Form Portlet

Regular Member 投稿: 135 参加年月日: 06/01/20 最新の投稿
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
16年前 に Gerfried Klein によって更新されました。

RE: Localization of Web Form Portlet

New Member 投稿: 8 参加年月日: 08/01/14 最新の投稿
thats right, I would like to have a full multi lingual web form, too, but its reasonable workaround.
thanx
thumbnail
16年前 に Pablo Mosquera Sáenz によって更新されました。

RE: Localization of Web Form Portlet

Junior Member 投稿: 61 参加年月日: 08/01/22 最新の投稿
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
16年前 に Ezequiel Chavez によって更新されました。

RE: Localization of Web Form Portlet

Regular Member 投稿: 135 参加年月日: 06/01/20 最新の投稿
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.