Announcement Announcement Module
Collapse
No announcement yet.
How to develop database entities with i18n support Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to develop database entities with i18n support

    Hi!

    I'm totaly new to spring and roo and have to evaluate, if we use roo
    for new projects in our company for the future.


    I18n support for templates is the static part, how can i add something
    like newsentries (id, published, category, ...) and newsentries_i18n (newsentry_id, locale, title, text, ...) as a dynamic part of website translation?


    Maybe i'm searching for the wrong terms with google and couldn't find
    a documentation for i18n entities.


    Hope that someone can help me
    regards,
    Sebastian

  • #2
    my suggestions

    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

    Comment

    Working...
    X