0

I need to make an internationalized (English and Arabic) application in grails, but I am facing some problems, for instance I got a domain named Students got the below fields: view plaincopy to clipboardprint?

Note: Text content in the code blocks is automatically word-wrapped

class Students  
{  
  String firstName  
  String lastName  
}  

In the views I want the above fields to be shown according to the language that the user selected in the welcome page.

I already made the part of language selection, but how the another part can be achieved?

4

1 回答 1

0

They are several different ways to handle internationalization.

For example by creating a sub class to wrap your fields:

class StudentFields
{  
  String firstName  
  String lastName  
}   

And then add 2 references (one for each locale):

class Students  
{  
  StudentFields english
  StudentFields arabic
}

Then you can access both languages using:

StudentsInstance.english.firstname

and

StudentsInstance.arabic.firstname

You can create a custom Tag to handle the logic (switching between english / arabic depending on the current locale) for your GSP.

于 2013-04-07T18:48:33.620 回答