You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@netbeans.apache.org by Jerome Lelasseux <le...@yahoo.com.INVALID> on 2020/12/21 14:56:34 UTC

[netbeans-platform] How to integrate UTF-8 .properties files efficiently?

I use the crowdin.com platform (free for open-source!) to get the translations done for my Netbeans RCP application. It gets synchronized automatically to GitHub nicely. 

The problem is that I pull UFT-8 encoded Bundle*.properties, and the RCP platform expects ISO-8859-1 encoding, so special characters got messed up.

Do you guys have experience how to integrate this seamlessly ?   (ideally by programmatically alter the behavior of the RCP framework so that UFT-8 is used to read .properties)


Thanks. Jerome





Re: [netbeans-platform] How to integrate UTF-8 .properties files efficiently?

Posted by Jerome Lelasseux <le...@yahoo.com.INVALID>.
> Well since unfortunately the encoding of a property file is set as ISO-8859-1 in it spec,
At least for JDK 11 the API says the opposite : https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/PropertyResourceBundle.html, see the API paragraph.
And indeed it's what I experiment: if I use ResourceBundle.getBundle(Class, Module),getString(key), it does automatically read UTF-8 or ISO strings (I made a test with both encodings in a single.properties file).
If I use NbBundle.getMessage() then it always expects ISO, that's why I don't use it. The problem is that I can't alter the behavior of the Netbeans internal stuff which still works the "old way". This impacts branding localization or action displayname declared via @ActionRegistration(lazy=true).



> I'd use a generator step in the build which would translate the UTF-8 characters into \uxxxx of the final Bundle.properties.
Yes, this is what I should try in the meantime... I'm not familiar with the And build-script, which target should I start with ? 




    Le lundi 21 décembre 2020 à 16:14:33 UTC+1, Laszlo Kishalmi <la...@gmail.com> a écrit :  
 
  
Well since unfortunately the encoding of a property file is set as ISO-8859-1 in it spec, I'd use a generator step in the build which would translate the UTF-8 characters into \uxxxx of the final Bundle.properties.
 
 On 12/21/20 6:56 AM, Jerome Lelasseux wrote:
  
 
 I use the crowdin.com platform (free for open-source!) to get the translations done for my Netbeans RCP application. It gets synchronized automatically to GitHub nicely. 
  
  The problem is that I pull UFT-8 encoded Bundle*.properties, and the RCP platform expects ISO-8859-1 encoding, so special characters got messed up.
  
  Do you guys have experience how to integrate this seamlessly ?   (ideally by programmatically alter the behavior of the RCP framework so that UFT-8 is used to read .properties)
  
  
  Thanks. Jerome
  
  
  
  
     

Re: [netbeans-platform] How to integrate UTF-8 .properties files efficiently?

Posted by Jerome Lelasseux <le...@yahoo.com.INVALID>.
 > With that, we could only recommend to take a break, go for running, ride a bike, etc.The best programmer advise indeed ! ;-)
I finally made a dirty hack: manually replacing the NbBundle .class files from org-openide-util.jar directly in the Netbeans/platform/lib folder ! It works fine.

I initially tried to do it in a cleaner way, using this page http://wiki.netbeans.org/DevFaqModulePatching   but could not make it work (valid for NB6 only?).
Yes, I'll make my first Netbeans PR to start 2021 :-)
And best wishes to all the NB team.

Jerome




    Le samedi 26 décembre 2020 à 18:21:56 UTC+1, Laszlo Kishalmi <la...@gmail.com> a écrit :  
 
  
Well, can you create a PR to see what would be your fix?
 Also unfortunately the " I've tried many things but no success." carries only information about your frustration. With that, we could only recommend to take a break, go for running, ride a bike, etc.
 
 On 12/26/20 8:52 AM, Jerome Lelasseux wrote:
  
 
 Well I've managed to alter my Ant build process to add UTF8>ISO5589-1  transcoding, but at the end of th day it's really not efficient...
  
  I came back to the source of the problem and checked NbBundle.java (part of org.openide.util/Base Utilities API module). It turns out it's easy to make it support UTF-8 as well, so I made the fix.
  
  Now I have trouble using this updated Netbeans code in my RCP application. I've tried many things but no success. What are the main steps to achieve this ? 
  
  Jerome 
  
  
  
      Le mercredi 23 décembre 2020 à 11:26:45 UTC+1, Jerome Lelasseux <le...@yahoo.com.invalid> a écrit :  
  
       > Well since unfortunately the encoding of a property file is set as ISO-8859-1 in it spec, I'd use a generator step in the build which would translate the UTF-8 characters into \uxxxx of the final Bundle.properties. 
 
 OK I've managed to use the -post-compile extension point to transcode the resource bundles in modules. 
 But how to do it for branding localized resource bundles ? I could not find any "hook" in the build scripts, it looks like it's a builtin task (see below from harness/suite.xml)
 
     <target name="branding" depends="-init" if="run.branding">
         <mkdir dir="${cluster}"/>
         <branding cluster="${cluster}" overrides="${branding.dir}" token="${branding.token}"  locales="${branding.locales.impl}"/>
     </target> 
     
     
            

Re: [netbeans-platform] How to integrate UTF-8 .properties files efficiently?

Posted by Laszlo Kishalmi <la...@gmail.com>.
Well, can you create a PR to see what would be your fix?
Also unfortunately the " I've tried many things but no success." carries 
only information about your frustration. With that, we could only 
recommend to take a break, go for running, ride a bike, etc.

On 12/26/20 8:52 AM, Jerome Lelasseux wrote:
> Well I've managed to alter my Ant build process to add UTF8>ISO5589-1  
> transcoding, but at the end of th day it's really not efficient...
>
> I came back to the source of the problem and checked NbBundle.java 
> (part of org.openide.util/Base Utilities API module). It turns out 
> it's easy to make it support UTF-8 as well, so I made the fix.
>
> Now I have trouble using this updated Netbeans code in my RCP 
> application. I've tried many things but no success. What are the main 
> steps to achieve this ?
>
>
> Jerome
>
>
>
>
> Le mercredi 23 décembre 2020 à 11:26:45 UTC+1, Jerome Lelasseux 
> <le...@yahoo.com.invalid> a écrit :
>
>
> > Well since unfortunately the encoding of a property file is set as 
> ISO-8859-1 in it spec, I'd use a generator step in the build which 
> would translate the UTF-8 characters into \uxxxx of the final 
> Bundle.properties.
>
>
> OK I've managed to use the -post-compile extension point to transcode 
> the resource bundles in modules.
>
> But how to do it for branding localized resource bundles ? I could not 
> find any "hook" in the build scripts, it looks like it's a builtin 
> task (see below from harness/suite.xml)
>
>     <target name="branding" depends="-init" if="run.branding">
>         <mkdir dir="${cluster}"/>
>         <branding cluster="${cluster}" overrides="${branding.dir}" 
> token="${branding.token}" locales="${branding.locales.impl}"/>
>     </target>
>
>
>

Re: [netbeans-platform] How to integrate UTF-8 .properties files efficiently?

Posted by Jerome Lelasseux <le...@yahoo.com.INVALID>.
 Well I've managed to alter my Ant build process to add UTF8>ISO5589-1  transcoding, but at the end of th day it's really not efficient...

I came back to the source of the problem and checked NbBundle.java (part of org.openide.util/Base Utilities API module). It turns out it's easy to make it support UTF-8 as well, so I made the fix.

Now I have trouble using this updated Netbeans code in my RCP application. I've tried many things but no success. What are the main steps to achieve this ?

Jerome



    Le mercredi 23 décembre 2020 à 11:26:45 UTC+1, Jerome Lelasseux <le...@yahoo.com.invalid> a écrit :  
 
 > Well since unfortunately the encoding of a property file is set as ISO-8859-1 in it spec, I'd use a generator step in the build which would translate the UTF-8 characters into \uxxxx of the final Bundle.properties.

OK I've managed to use the -post-compile extension point to transcode the resource bundles in modules.
But how to do it for branding localized resource bundles ? I could not find any "hook" in the build scripts, it looks like it's a builtin task (see below from harness/suite.xml)

    <target name="branding" depends="-init" if="run.branding">
        <mkdir dir="${cluster}"/>
        <branding cluster="${cluster}" overrides="${branding.dir}" token="${branding.token}"  locales="${branding.locales.impl}"/>
    </target>
    
    
  

Re: [netbeans-platform] How to integrate UTF-8 .properties files efficiently?

Posted by Jerome Lelasseux <le...@yahoo.com.INVALID>.
> Well since unfortunately the encoding of a property file is set as ISO-8859-1 in it spec, I'd use a generator step in the build which would translate the UTF-8 characters into \uxxxx of the final Bundle.properties.

OK I've managed to use the -post-compile extension point to transcode the resource bundles in modules.
But how to do it for branding localized resource bundles ? I could not find any "hook" in the build scripts, it looks like it's a builtin task (see below from harness/suite.xml)

    <target name="branding" depends="-init" if="run.branding">
        <mkdir dir="${cluster}"/>
        <branding cluster="${cluster}" overrides="${branding.dir}" token="${branding.token}"  locales="${branding.locales.impl}"/>
    </target>
    
    

Re: [netbeans-platform] How to integrate UTF-8 .properties files efficiently?

Posted by Laszlo Kishalmi <la...@gmail.com>.
Well since unfortunately the encoding of a property file is set as 
ISO-8859-1 in it spec, I'd use a generator step in the build which would 
translate the UTF-8 characters into \uxxxx of the final Bundle.properties.

On 12/21/20 6:56 AM, Jerome Lelasseux wrote:
> I use the crowdin.com platform (free for open-source!) to get the 
> translations done for my Netbeans RCP application. It gets 
> synchronized automatically to GitHub nicely.
>
> The problem is that I pull UFT-8 encoded Bundle*.properties, and the 
> RCP platform expects ISO-8859-1 encoding, so special characters got 
> messed up.
>
> Do you guys have experience how to integrate this seamlessly ?   
> (ideally by programmatically alter the behavior of the RCP framework 
> so that UFT-8 is used to read .properties)
>
>
> Thanks. Jerome
>
>
>
>