Announcement Announcement Module
No announcement yet.
Adding a new language to a project Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Adding a new language to a project

    Hi there !

    I created a new project with SpringRoo 1.2.
    I used the reverse engineering to generate all the BO objects, the service layer and the UI pages.

    Now I try to internationalize my application.

    I added the 6 languages handled by default by SpringRoo without any trouble.

    Now I have several questions :

    1) why are there only 6 languages handled by default ? I saw several properties files for other languages on internet : maybe they could be added ?

    2) I tried to add new languages but it is very hard (at least for me...). I didn't understand the story about creating an i18n project ... but I found two existing project around French and Russian. I tried to add them using those two Roo commands :
    osgi start --url
    osgi start --url
    ... but this didn't work :'(
    The first one added the file, the russian flag icon and changed the footer.jspx file ! But when I cliqued on the flag, I had the english language ...
    I created the file, added the expected icon and changed the footer.jspx file ... same result !
    I tried a lot of changes, install, uninstall, and ... suddenly, I don't know why, but it worked !

    3) now I try to add portuguese language ... I added the properties file, the icon and changed the footer.jspx file ... but it doesn't work :'(
    My question main is : all the structure is set so that the application can switch from one language to another, just by specifying the 2 letters country code :
    <util:language label="English" locale="en"/>
    <util:language label="Franšais" locale="fr"/>
    So why isn't it possible to simply add a new property file and a new button to make it works ?

    Thanks in advance for attention.


  • #2
    Roo has a convenient, built-in add-on discovery mechanism which does exactly what you need:

    roo> addon search french
    1 found, sorted by rank; T = trusted developer; R = Roo 1.2 compatible
    ID T R DESCRIPTION -------------------------------------------------------------
    01 Y - 0.1.0.BUILD France language support for Spring Roo Web MVC JSP
    [HINT] use 'addon info id --searchResultId ..' to see details about a search result
    [HINT] use 'addon install id --searchResultId ..' to install a specific search result, or
    [HINT] use 'addon install bundle --bundleSymbolicName TAB' to install a specific add-on version
    ~.web roo> addon install id 1
    Target resource(s):
       spring-roo-addon-french (0.1.0.BUILD)
    Successfully installed add-on: spring-roo-addon-french [version: 0.1.0.BUILD]
    [Hint] Please consider rating this add-on with the following command:
    [Hint] addon feedback bundle --bundleSymbolicName org.springframework.roo.addon.french --rating ... --comment "..."
    ~.web roo> web mvc language --code fr
    ec3fc44 Created SRC_MAIN_WEBAPP/WEB-INF/i18n/
    0f67f12 Created SRC_MAIN_WEBAPP/images/fr.png
    46d0f10 Updated SRC_MAIN_WEBAPP/WEB-INF/views/footer.jspx
    This is also documented in our reference guide. The i18n addon creation steps are outlined here and here.



    • #3
      Hello Stefan,

      thank you for taking time to have a look at my problem !

      As I said in my previous message, I managed to make work the French and the Russian languages, using the add-on discovery mechanism and some web search.

      The problem I have is : how adding a new language that is not supplied in the add-on list ?
      I'm trying to add Portuguese language : I have the file and the flag icon, I tried to create the i18n stuffs like this (but it fails) :
      roo> addon create i18n --topLevelPackage com.myCompany.myProject --locale pt --messageBundle SpringRooI18nAddons/pt/
      Command 'addon create i18n --topLevelPackage com.vialtis.ferry --locale pt --messageBundle SpringRooI18nAddons/pt/' was found but is not currently available (type 'help' then ENTER to learn about this command)
      Did I miss something ?



      • #4
        The addon create command will only work in empty directories. This is because it will create a complete new project for your addon so you can package it as a (OSGi-ready jar bundle, and potentially make it available to other Roo users). Once you have created your addon project and packaged it (mvn package) you can install the addon:

        roo> osgi start --url file:///<path-to-jar>foo.jar


        • #5
          Hi I'm having problems too when "Adding a new language to a project"
          I want to make locale for Bosnian language in Latin and Cyrillic ( So i will have to commands
          addon create i18n --topLevelPackage spring.roo.addon.mvc.i18n.bosnian.Cyrillic --locale bs_cy --messageBundle --language Bosanski --flaggraphic bs.png --description "Localization for Bosnian Cyrillic"

          addon create i18n --topLevelPackage spring.roo.addon.mvc.i18n.bosnian.Latin --locale bs_la --messageBundle --language Bosanski --flaggraphic bs.png --description "Localization for Bosnian Latin"

          And when I add them
          osgi start --url file:///....\spring.roo.addon.mvc.i18n.bosnian.cyrillic-0.1.0.BUILD-SNAPSHOT.jar
          osgi start --url file:///....\spring.roo.addon.mvc.i18n.bosnian.latin-0.1.0.BUILD-SNAPSHOT.jar

          In project in roo I can see them

          roo>web mvc language --code
          bs_la bs_cy de en es it nl sv

          but i'm getting exception
          java.lang.IllegalStateException: Failed to convert 'bs_cy' to type I18n for option ',code'
          when adding language

          roo> web mvc language --code bs_cy
          java.lang.IllegalStateException: Failed to convert 'bs_cy' to type I18n for option ',code'

          One strange thing is if I issue
          addon create i18n --topLevelPackage spring.roo.addon.mvc.i18n.bosnian.Cyrillic --locale bs_cy --messageBundle --language Bosanski --flaggraphic bs.png --description "Localization for Bosnian Cyrillic"

          I have to modify in BosanskiLanguage class bs -> bs_cy

          @Component(immediate = true)
          public class BosanskiLanguage extends AbstractLanguage {

          public Locale getLocale() {
          return new Locale("bs");//change to bs_cy

          public String getLanguage() {
          return "Bosanski";

          public InputStream getFlagGraphic() {
          return FileUtils.getInputStream(getClass(), "bs.png");

          public InputStream getMessageBundle() {
          return FileUtils.getInputStream(getClass(), "");


          • #6
            I know this is old but thought it was worth adding in, just in case others are looking.

            I was able to add a new language to my Spring Roo JSF project just by:
            1. Adding the image and link in the footer.
            2. Creating the associated messages_<xx>.properties file
            3. Adding in the language support to the faces config: (faces-config.xml)