0

I'm building a web application that needs to send a confirmation email at the end of the registration process. The text of the email should be localized.

What I initially did was to build the email on the client-side, but I don't really like the idea of all this data going from the client to the server. Also, one could access the javascript code and hack the message.

If I build the email on the server side I will loose the localization.

What is the best approach in this case?

EDIT: My question is not really about using i18n on the server side, but if it's correct to build the email on the client side.

algiogia
  • 936
  • 2
  • 14
  • 40
  • 1
    Why do you lose localization if you build the email on the server? – Thilo May 08 '14 at 08:12
  • @Thilo, GWT localized resources are only available on the client-side: the server doesn't know the client's locale. What I mean is that you cannot use the Messages or Constants interfaces. – algiogia May 08 '14 at 08:37
  • @Baz I am not asking how to access i18n on the server, but what is the best way to go in my case. – algiogia May 08 '14 at 08:39
  • @algiogia And the answer to that question can be found in the link i posted. Use the default Java way of doing it. – Baz May 08 '14 at 08:41
  • @Baz can I reuse the same resource file I use for GWT? – algiogia May 08 '14 at 08:42
  • @algiogia Almost certain you can. Not sure it works if you're using plural forms and things like that though. – Baz May 08 '14 at 08:45
  • @algiogia [This](http://stackoverflow.com/a/18078978/1740724) answer suggests that you can use them as they are. – Baz May 08 '14 at 08:47
  • @algiogia Since you have to send the email from the server anyway, it's best to create it there as well. That way you can make sure that there is no manipulation of any sort. You can send the locale to the server, then use `ResourceBundle` to get the i18n text and create the email. – Baz May 08 '14 at 11:59

0 Answers0