Properties file native2ascii conversion

Helo all,
We've implemented properties file support at the top of the new Language
API.
(File format described here:
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html#load(java.io.InputStream)
)

And now we are considering new feature: transparent conversion from
Unicode-escaped characters (\uxxxx) to native characters.
E.g. if you are editing properties file containing escaped sequences for
Japanese messages, it will show up as Japanese text in the IDEA editor, and
will be saved back as Unicode escaped characters.

Please express your opinions whether
- the feature is useful. (How your build process is arranged w.r.t
properties file storage/conversion ?)
- we need option to switch the feature on/off. (And as I suspect we will
need this option, what is the best place for it ?)

--
regards,
Alexey Kudravtsev
Software Developer
JetBrains, Inc, http://www.jetbrains.com
"Develop with pleasure!"


17 comments
Comment actions Permalink

+1,very good!

0
Comment actions Permalink

I'd like to see a complementary feature that allows me to have it convert native charaters to their unicode-escaped alternative but still show them as the native charaters.

Must always be optional whether or not the escape characaters are rendered as native characters though.

1
Comment actions Permalink

Alexey Kudravtsev (JetBrains) wrote:

Helo all,
We've implemented properties file support at the top of the new Language
API.
(File format described here:
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html#load(java.io.InputStream)
)

And now we are considering new feature: transparent conversion from
Unicode-escaped characters (\uxxxx) to native characters.
E.g. if you are editing properties file containing escaped sequences for
Japanese messages, it will show up as Japanese text in the IDEA editor, and
will be saved back as Unicode escaped characters.

Please express your opinions whether
- the feature is useful. (How your build process is arranged w.r.t
properties file storage/conversion ?)
- we need option to switch the feature on/off. (And as I suspect we will
need this option, what is the best place for it ?)

yeah!!

+100 from me

1
Comment actions Permalink

That was exactly what I mean: "render unicode-escaped sequences as native
characters in editor, but keep them escaped on disk".
What do you think is the most intuitive place for this option ?

--
regards,
--
Alexey Kudravtsev
Software Developer
JetBrains, Inc, http://www.jetbrains.com
"Develop with pleasure!"

"Patrik Andersson" <pandersson@gmail.com> wrote in message
news:29127633.1113822408807.JavaMail.itn@is.intellij.net...

I'd like to see a complementary feature that allows me to have it convert
native charaters to their unicode-escaped alternative but still show them
as the native charaters.

>

Must always be optional whether or not the escape characaters are rendered
as native characters though.



0
Comment actions Permalink

If IDEA developers can cooperate with PE's authors,I think IDEA will be more powerful with properties file editing. Dmitry Kashin seem to be very busy,and has no time to update this plugin. :) I like this plugin very much,if you have more idea about properties file,we will get more joys. Thanks.

0
Comment actions Permalink

- the feature is useful. (How your build process is
arranged w.r.t
properties file storage/conversion ?)


OMG, it's sure useful! Using property files for text messages is a pain if you're developing for any other language besides english. While I still think the \u thing is still dumb (I have a custom ResourceBundle implementation that takes files in any encoding, determined by a comment in the first line, defaulting to UTF-8), it would really easy the life of those of us that depends on property files for internationalization.

- we need option to switch the feature on/off. (And
as I suspect we will
need this option, what is the best place for it ?)


Hmm... problem is, if there was an option for this, it would probably be per file (otoh, I always thought that the character encoding option should be per-file too). Anyways, this is an editor feature, so it should be on the "Editor" preferences panel.

0
Comment actions Permalink

Guess I was tired when I read your post. What you wrote makes absolute sense of course.

Are unicode escape-sequences something that is going to be recognized for more than one file-type? I can see how that would also be a nice feature for the Java Editor aswell as the JSP one. If that were the case, then a checkbox in IDE

Settings -> Editor -> Display
Render unicode-escaped sequences as native characters

would be something I'd look for.

Another option, albeit not as good, would be to stick that under:

IDE Settings -> Code Style -> General

Or how about:

Main Menu -> View -> Render unicode-escaped sequences as native characters (CheckboxMenuItem)

But putting it there clutters the menu even more.

0
Comment actions Permalink

it would really easy the life of those of
us that depends on property files for
internationalization.


I know, replying to yourself tells the world how much you need a hug, but anyways...

My above message hinted on one strong usage patterns: The number one use for property files is internationalization, and that's exactly why they're a pain to deal with. When we're coding for multiple languages, we'll input text in multiple charsets, and yet Java limits us to ISO-8859-1. Implementing this automatic translation would sooth just a portion of our pain, as we would not have to worry about the \u encoding.

Now, why not tackle the whole problem at once and implement a full-fledged resource bundle editor (or at least a RB viewer): an editor where you could edit a base file (messages.properties) and it's multiple alternatives (messages_pt_BR.properties, messages_ja_JP.properties) at the same time. This could probably be implemented as a two-pane editor: base file on one side, selected translation on the other side.

I've been using Attesoro[1] for editing my resources bundles. While it works, and has really nice features, it's ugly as hell and it would be nice to have something like it integrated into IDEA.

http://ostermiller.org/attesoro/

0
Comment actions Permalink

+100. We need it, really !!!
Where to put the on/off - may be it's time to implement dynamic toolbars (tab content dependent) or directly in-tab toolbars (see NetBeans 4, 4.1) and put this option there.

0
Comment actions Permalink

Please do not add any automatic conversion without notifying the user before.
Like Marcus we also use a custom resource bundle loader: Our properties files are encoded in utf-8 and must stay in this encoding.

0
Comment actions Permalink

Alexey Kudravtsev (JetBrains) wrote:

We've implemented properties file support at the top of the new Language
API.
(File format described here:
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html#load(java.io.InputStream)
)


On a related note, will this make properties files accessible via PSI?
So that I could inspect and edit the contents of a properties file like
I can with a Java file in a plugin?

Ciao,
Gordon

--
Gordon Tyler (Software Developer)
Quest Software <http://www.quest.com/>
260 King Street East, Toronto, Ontario M5A 4L5, Canada
Voice: (416) 933-5046 | Fax: (416) 933-5001

0
Comment actions Permalink

Yes

-


Maxim Shafirov
http://www.jetbrains.com
"Develop with pleasure!"

Alexey Kudravtsev (JetBrains) wrote:

>> We've implemented properties file support at the top of the new
>> Language
>> API.
>> (File format described here:
>> http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html#loa
>> d(java.io.InputStream)
>> )

On a related note, will this make properties files accessible via PSI?
So that I could inspect and edit the contents of a properties file
like I can with a Java file in a plugin?

Ciao,
Gordon



0
Comment actions Permalink

For developers still using the old (and IMHO, silly) language resource JDK implementation, there is this wonderful tool:

http://zaval.org/products/jrc-editor/

It handles nativeToAscii conversion transparently, and supports several languages at the same time, with powerful filtering and add/remove key function across several languages...

But to be fair, I don't care anymore as I've completely rewritten the implementation to handle my key-value mappings in a more efficient way, using the new map/collections structures and with full support for UTF-8.

I use the properties files for language resources and configuration files.
XML hasn't made it to my applications because of the overhead it creates.

0
Comment actions Permalink

Silly or not, if U use Struts what's the choice ?

0
Comment actions Permalink

... and, btw., we all know the tool, but may I remind U that IDEA is INTEGRATED development environment. If it's up to something that's not IDEA, then SunONE Studio has the perfect property editor, but ... what's the point ?

0
Comment actions Permalink

... and, btw., we all know the tool, but may I remind
U that IDEA is INTEGRATED development environment. If
it's up to something that's not IDEA, then SunONE
Studio has the perfect property editor, but ...
what's the point ?


I mention Zaval JRC Editor because I believe it's how a resource editor should be like in IDEA ! ;)

Would it be possible to have a streamline integration of language resource management, so that for example there would be auto-completion of dot-separated language keys from the JAVA source code, not the .properties editor, with some sort of intention feature to add the key automatically in the .properties repository, across multiple languages ? Wouldn't it be nice if IDEA could tell us about missing translated strings, as a warning when compiling / editing. And also, I would love to see a feature that tells me what language keys are unused, so I can clean my language properties files. Of course, during all this process, non-ASCII characters are handled transparently.

0
Comment actions Permalink

Excellent ideas !

0

Please sign in to leave a comment.