2

I want to internationalize my Java Web Application and followed this guide by BalusC using JSTL. It works very well. But I have a question concerning big texts (meaning > 5000 characters long html text). I also simply translated them like all the other texts and put them into the resource bundle. My english text.properties file looks something like this e.g. for a site explaining the rules of a game:

sidebar.rulesLink=Rules
sidebar.supportLink=Support
etc..

rules.title=Rules
rules.text=<p>Many paragraphs with about 8000 characters.</p>

support.title=Support
support.text=<p>Many paragraphs with about 5000 characters.</p>

So the properties files get relatively big. But is this really the correct approach? Or should I handle big texts in an other way?

EDIT: I wondered if for example this approach would look and perform better for huge text sites?:

...
<body>
<h1><fmt:message key="rules.title" /></h1>
<c:choose>
    <c:when test="${language=='de'}">
        <c:import url="rules-de.inc.html"></c:import>
    </c:when>
    <c:otherwise>
        <c:import url="rules-en.inc.html"></c:import>
    </c:otherwise>
</c:choose>
</body>
...

And in the rules-xx.inc.html the html text is stored and gets included depending on which language is selected.

Community
  • 1
  • 1
RemmiDemmiSemmi
  • 123
  • 1
  • 7
  • What are you considering? It should be fine. If it isn't, I might consider a separate text file for "long" sections, or maybe a database table. I guess the real question is what about the above approach do you want to change? – Elliott Frisch Jun 05 '14 at 12:56
  • Oh, this approach works well but I am just not sure if is is the correct one as the propoerties files does not look nice with some lines just one word assigned and then again huge textblocks without any blank lines as this would interrupt the current key. Also I am not sure if the whole properties file (including all the text) gets loaded when a single site is loaded? – RemmiDemmiSemmi Jun 05 '14 at 13:04
  • I believe the entire file gets loaded when the first value is read for the first time. – Elliott Frisch Jun 05 '14 at 13:06
  • I edited my question and added an other approach I would consider. What do you think about that? – RemmiDemmiSemmi Jun 05 '14 at 13:12
  • If the pages are very static, that looks like it would work to me. – Elliott Frisch Jun 05 '14 at 13:25
  • I thing it should be OK, but it seems à little strange to me. If you have large texts, I suppose that they represent at least full paragraphs. You risk to have a lot of duplication, and it will be more tedious to keep all those large strings in sync. But it should work fine on a technical view. – Serge Ballesta Jun 05 '14 at 14:44
  • I believe importing HTML makes more sense. However, it depends on how you localize it. If your translation providers have tools to work effectively with HTML, I don't think it is a real problem. If they don't turning this HTML into JSP and externalizing texts in smaller chunks might be a good idea. – Paweł Dyda Jun 05 '14 at 19:38

1 Answers1

0

I would change the HTML version into something like this:

<body>
  <h1><fmt:message key="rules.title" /></h1>
  <c:import url="rules-${language}.inc.html"></c:import>
</body>

I am not sure about the syntax but the idea should be clear: naming the html files with their language as part of their name makes it easier to retrieve the right one with a substitution rule.

Edoardo
  • 4,485
  • 1
  • 27
  • 31