gwtproject / gwt

GWT Open Source Project
http://www.gwtproject.org
1.53k stars 378 forks source link

"unterminated single quote" error when compling property file #2235

Closed dankurka closed 9 years ago

dankurka commented 9 years ago

Originally reported on Google Code with ID 2229

Found in GWT Release:
latest trunk as of 03/28/2008

Detailed description:
I updated my trunk today with old modification of kitchensink sample. Ant
build failed when compiling KitchSink samples. I have local modification
which extract hardcoded string to property files. The error is like:
    [java]             Processing interface
com.google.gwt.sample.kitchensink.client.KitchenSinkMessages                  
     [java]                Generating method body for IntroDescription()  

     [java]                   [ERROR] Unterminated single quote:
<h2>Kitchen Sink ??</h2><p>?????????.?????????????????    
: <p>??????.  ????????????????????<i>????</i>
??????????bookmarkable????????????????????????????????????????????????' ?    
????????????firefox ? ? </p> </p>                                         

     [java] [ERROR] Errors in
'C:\gwt\trunk\samples\kitchensink\src\com\google\gwt\sample\kitchensink\client\KitchenSin

k.java'                                                                   

     [java]    [ERROR] Line 34:  Failed to resolve
'com.google.gwt.sample.kitchensink.client.KitchenSinkMessages' via d    
eferred binding                                                           

     [java] [ERROR] Cannot proceed due to previous errors                 

     [java] [ERROR] Build failed                               

Some further experiment shows that GWT is looking for a matching pair
whenever it hit a single quote. So string like "here's ...." will have this
kind of problem. 

This problem did not exist before. Java property file does not have this
kind of restriction either. This issue will cause big headache for
localization.

Workaround if you have one:
None.

Links to the relevant GWT Developer Forum posts:

Reported by shanjianli on 2008-03-28 20:46:09

dankurka commented 9 years ago
This is not a bug -- the GWT Messages interface is defined to follow that of
MessageFormat, and MessageFormat requires isolated single quotes to be doubled.  See
http://java.sun.com/j2se/1.5.0/docs/api/java/text/MessageFormat.html for details.

Reported by gwt.team.jat on 2008-03-28 21:24:36

dankurka commented 9 years ago
BTW, if you don't want any quoting and don't need arguments, you can use Constants
instead and avoid any the requirement to double single quotes.

Reported by gwt.team.jat on 2008-03-28 21:31:02

dankurka commented 9 years ago
unfortunately this limitation also applies to properties defined with <ui:msg key="myKey">
elements defined in uibinder templates. This makes it quite hard for translators to
work with. Either you instruct them to turn every quote into a double quote or you
do it yourself....

Reported by googelybear on 2011-03-09 14:41:29

dankurka commented 9 years ago
Well, you have to have some way of supporting the necessary quoting - what if the translator
needs to put a literal { or } in the message?  If they aren't quoted, they will be
interpreted as starting an argument.  If you are handing translators property files
directly, then they need to understand what the format looks like and be able to process
it accordingly.  If you are using some other format for your translators, then you
can write a small program to convert to/from the GWT properties format, or write your
own exporter (and eventually GWT will support pluggable importers).

Reported by jat@google.com on 2011-03-09 15:05:26