Hi,
I have a few dropdown lists in my projects and they support well any number of languages really, currently I support two languages.
I use jinto for the i18n part (jinto - http://www.guh-software.de/eclipse) and then I standardized all my support tables.
example : this is one of my dropdown tables, this one is to contain academic degrees
Code:
public class AcademicDegree {
@NotNull
@Size(min = 1, max = 255)
private String description_en;
@NotNull
@Size(min = 1, max = 255)
private String description_label;
@Size(min = 1, max = 255)
private String description;
}
example of entries in database table academic_degree
(id, description, description_en, description_label)
(-1, ' ','-- nothing selected --','academic_degree')
(1, ' ','Doctorate','academic_degree_1')
and then I have matching entries in the application.properties file
label_is_rannis_sjodir_taxform_domain_dropdown_aca demic_degree_1=doctorate
and another in the application_is.properties file for icelandic.
then I have a slight trick in my .jspx file to translate between languages
as you may have noticed my description column is emtpy
but my description_label column is really the name of the label to use for translation in the application.properties file
Code:
<c:forEach items="${academicdegrees}" var="degree">
<spring:message code="label_is_rannis_sjodir_taxform_domain_dropdown_${degree.description_label}" var="test"/>
<jsp:setProperty name="degree" property="description" value="${fn:escapeXml(test)}"/>
</c:forEach>
and then lastly, applicationconversionservicesfactorybean.java has to have a converter like this.
Code:
org.springframework.core.convert.converter.Converter<AcademicDegree, String> getAcademicDegreeConverter() {
return new org.springframework.core.convert.converter.Converter<AcademicDegree, String>() {
public String convert(AcademicDegree academicDegree) {
return new StringBuilder().append(academicDegree.getDescription()).toString();
}
};
}
which basicly returns the description column and nothing else.
hope this helps.
regards,
Emil