java - Multilenguage data in web application -


I am developing a web application about restaurant management, and I want to store different categories and my language Election. I am using my SQL and my application has been developed in Java + Spring + Hibernate + Tapestry. how can I do this? Store names in databases in three or four languages?

OK I calculate my answer here and describe some details, Was not included in.

Create. * Properties file that you plan to use. For example their content:

I18n_en.properties

category.dinners = dinner

I18n_es.properties < Blockquote>

category.dinners = babidas

The user clicks on the button or link on the site, and the server receives the request-parameter, for example locale = n.

The code can be anything to create a site-page:

  string path = ...; // --- * .properties paths of folders with files if (locale.equals ("en")) path + = "I18n_en.properties"; Other path + = "I18n_es.properties"; FileInputStream fis = New FileInputStream (path); Resource bundle resource bundle; {Try ResourceBundle = new PropertyResourceBundle (fis); } Finally {fis.close (); }   

Your category object must have 'name' property. In this 'name' *. In our case - name = "category.dinners".

You get the Category object from the database. You now have to enter the text in the required location:

  string htmlForResponse = ...; // --- Your HTML-page HTML forensons + = "& lt; div & gt;" + resourceBundle.getString (category.getName ()) + "& lt; / div & gt;";   

This is not the best solution, it only shows you some possible steps, good luck!

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -