We’ve recently had a problem where we wanted to produce a website in multiple languages including Russian, Czech, Romanian, and other eastern European languages. No problems, we thought, we can just use Java properties files and the
fmt:message JSTL tags. Continue reading Localisation in Java
I’ve been having problems with putting unicode strings into the subject of emails sent using javax.mail.
In the end, the solution was very simple and I found it here:
As long as you use “UTF-8” and not “UTF8” it all seems to work fine, so the code you need is:
Properties props = new Properties();
// put in your SMTP host in here
Session s = Session.getInstance(props, null);
MimeMessage message = new MimeMessage(s);
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
message.setHeader("Content-Type", "text/plain; charset=UTF-8");
Further to my post about creating properties files when I had text files in unicode, we decided that the best thing was to have a web application to do the conversion. You can then just paste in whatever text you want to encode and it tells you what the java escaped text string(s) should be.
And, we decided we might as well make it publicly available. So here it is.
Let us know if you find any bugs or if you can think of a better way to do it
We recently had what sounded like a simple job to do: produce a questionnaire in several languages including Russian and store the results in a MySQL database. Now I could have chosen PHP to produce the questionnaire, but I thought that using Java resource bundles would be the easiest. I knew that using the JSTL fmt: tags we could do fmt:message and pull the messages out of a resouce bundle so all I had to do was get the translators to take the english property file, translate it and hey presto! Java knows about Unicode right into its core, so it would all work wouldn’t it.
How wrong I was! Continue reading Internationalising JSPs