[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[ui-best-practices-working-group] How do you handle apostrophes?

Hi,

I have a general question about the localization architecture of Eclipse (or Java-based applications in general); please redirect me if this is not the right forum to ask.

My question is this: how do handle the apostrophe character? It is problematic for two reasons: first, the FormatMessage Java class treats it as an escape character and therefore, messages that are passed to this class must contain doubled apostrophes ('') instead of single ones ('). Since translators have no idea whether a message is processed via FormatMessage or not, they have no clue whether they should double their apostrophes or not.

The other problem is similar to this: if HTML output is generated via JSP pages and the page contains dynamically generated JavaScript, we hit the same problem again if the code uses constructs like this:

System.out.println("alert('" + bundle.getString(ALERT_MSG) + "');");

This will throw a JavaScript syntax error if the message happens to contain an apostrophe character. Again, the translator who is workin on the message file (.properties or whatever format) only, would not know that the apostrophe character needs to be written as \u0027 in this case.

Is there a generally accepted solution or best practice to tackle these situations?

Thanks,
Peter

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/