Solved

Ant Script ? to pad strings during build process? Other Script?  Best way?

Posted on 2012-04-02
1
663 Views
Last Modified: 2012-04-04
Experts:

I need to take .properties files with Key=value lists in them and pad the value (String) with characters to generate pseudo-localization (fake Languages) files during the build process.  I don't know anything about Ant.  Not sure if that is what I should be researching.  Looking for best solution.  Anybody out there know of a best solution?

To be more clear:

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 in advance,
Patricia
0
Comment
Question by:pdlarue
1 Comment
 

Accepted Solution

by:
pdlarue earned 0 total points
ID: 37807583
OK.  The way to do this is a simple Java app. 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...

This information came from Peter Johnson at www.coderanch.com.

Thanks, Peter.

Patricia
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now