aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes Creating pseudo-localization files with Ant, Maven, other scripting tools, or java during build proc Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Creating pseudo-localization files with Ant, Maven, other scripting tools, or java during build proc" Watch "Creating pseudo-localization files with Ant, Maven, other scripting tools, or java during build proc" New topic
Author

Creating pseudo-localization files with Ant, Maven, other scripting tools, or java during build proc

Patricia LaRue
Greenhorn

Joined: May 03, 2004
Posts: 4
Hello:

I'v'e been told that Ant PropertyFile can be used to concatinate strings to the values in a .properties file during the build process. I looked into that. That's good. But I need to calculate 50% longer string and append to the value half the characters to the front of the string and half to the back of the string. Can I do this with Ant? What is the best approach?

Thank you in advance,
Patricia
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5842
    
    7

I'm sorry, but I did not follow that. Could you give a concrete example of exactly what you want to do?

I suspect that you might want to look at some of the tasks in the antcontrib library: http://ant-contrib.sourceforge.net/


JBoss In Action
Patricia LaRue
Greenhorn

Joined: May 03, 2004
Posts: 4
English version of .properties file:

BUTTON.Del=Delete
BUTTON.CONNECT=Connect To
BUTTON.CONNECT_TO=Connect to {0}
COL_HEAD.TYPE=Type
COL_HEAD.DIRECTION=Direction
SELECTONERADIO.WATTS=Watts
SELECTONERADIO.Amps=Amps
BUTTON.LOAD=Load
BUTTON.OK=OK
BUTTON.YES=Yes
BUTTON.NO=No

Italian pseudo-localization version of .properties file:

BUTTON.Del=à Deleteà
BUTTON.CONNECT=à éConnect Toà é
BUTTON.CONNECT_TO=à é Connect to {0}à é
COL_HEAD.TYPE=à Typeà
COL_HEAD.DIRECTION=à éDirectionà é
SELECTONERADIO.WATTS=à Wattsà
SELECTONERADIO.Amps=à Ampsà
BUTTON.LOAD=à Loadà
BUTTON.OK=àOKà
BUTTON.YES=àYesà
BUTTON.NO=àNoà

You will notice that the English version contains English string values. I need to read in each line, calculate the length of the string value, and pad non-English characters to the front and the back of the English string until the newly created string value is 50% longer than the original English string. This is how one creates pseudo-localization files for Internationalizing and testing an application. Therer are tools out there that will do this, however, they are manual intensive. I need to create a script to do this with the build. I know others have created these scripts, I just don't know what they used. Someone said that Ant PropertyFile can be used to concatinate strings to the values in a .properties file during the build process. But from the documentation I saw, the ability was a little primitive (like only adding the characters you specify). I need to resize the string to 50% longer. So, I'm looking for best way to do this.

Thank you,
Patricia

Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5842
    
    7

I don't think Ant is what you want. A simple Java app should be able to do it though: have the app read the properties files as a, well, properties file! Then have it loop through the properties and create another file with the contents you want using the substring method to add 1/2 of the original value onto the value. This shouldn't take but about an hour and maybe 20-30 lines of code. (For bonus points, implement this as an Ant task or a Maven plugin...)

Or if you ever want to learn Groovy (or Python, or ...), this looks like the perfect opportunity...
Patricia LaRue
Greenhorn

Joined: May 03, 2004
Posts: 4
Thanks, Peter, I thought that would probably be the way to do it but I wanted to be sure I wasn't missing some functionality that would be a better approach. I'm on the correct path.

Thank you, again,
Patricia
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Creating pseudo-localization files with Ant, Maven, other scripting tools, or java during build proc