Use GWiki I18N outside GWiki

For internationalisation Java uses properties files to provide text elements for different languages.
GWiki can be used to online maintainging this international texts.

Create I18N-Elements

Inside GWiki you can create I18N Files containing properties files for different languages.
If you want use the I18N Keys in pages which has no gwiki authentification, you have to give GWIKI_PUPLIC for read access (See Settings in the I18N Page Editor).

Make usage of

GWiki provides an Servlet Filter, which has to inserted in the web.xml:

<filter>
		<filter-name>gwiki18n</filter-name>
		<filter-class>de.micromata.genome.gwiki.page.impl.i18n.GWikiI18NServletFilter
		</filter-class>
		<init-param>
			<param-name>I18NModules</param-name>
			<param-value>edit/StandardI18n</param-value>
		</init-param>
	</filter>

The I18NModules value contains a comma seperated list of pages containing GWiki I18N Elements. This elements are used to translate the I18N Keys.

<filter-mapping>
		<filter-name>gwiki18n</filter-name>
		<url-pattern>*.jsp</url-pattern>
	</filter-mapping>

Add a filter mapping (*.do, *.action, depending which framework you use) to the page URLs, which containing I18N Keys.

If you have another filter, which provides I18N-Mechanism, add the filter mapping of GWIKi at last position. In this case GWiki delegates translation to the previsous filter.

In you JSP-File you can now using the fmt:message tag:

<%@ taglib uri="/WEB-INF/tlds/c-rt.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/tlds/fmt-rt.tld" prefix="fmt"%>
<html>
<head>
<script type="text/javascript"
	src="<c:url value="/gwiki/static/js/jquery-1.4.min.js"/>"></script>
<script type='text/javascript'
	src="<c:url value='/gwiki/static/js/jquery.bgiframe.min.js'/>"></script>
	<script src='<c:url value="/gwiki/static/js/jquery.contextmenu.js"/>' type="text/javascript"></script>
<script type="text/javascript"
	src="<c:url value="/gwiki/static/gwiki/gwiki-i18n-contextmenu-0.3.js"/>"></script>
<style type="text/css">
.gwiki18nk {
	background-color: #EEEEEE;
}
</style>
</head>
<body>
<div id="gwikii18nmenu" style="font-size:0.7em;display:none;width:650px;background-color:white;border:1px solid black;padding:5px;"></div>

<h1>GWiki I18N Example.</h1>
This is a <fmt:message key="gwiki.page.headmenu.Page" /> and a message: <fmt:message key="gwiki.edit.EditPage.label.noNotificationEmails" />.

</body>
</html>

Inline Editing

To enable Inline editing set in request the variable gwiki18ndeco to true:

pageContext.getRequest().setAttribute("gwiki18ndeco", "true");

If the current user has the right to edit the underlying I18N element, the values can directly edited by the right context menu.
You can use the gwiki18nk style to higlight the used i18n Keys.

This page will be shown as:


Last modified 2010-04-14 13:29 by rkommer. ViewCount: 12998
By Roger Rene Kommer r.kommer@micromata.de and Micromata