net.nand.util.i18n
Class PropsFilePseudoLocalizer

java.lang.Object
  extended by net.nand.util.i18n.PropsFilePseudoLocalizer

public class PropsFilePseudoLocalizer
extends java.lang.Object

Given a simple .properties file, pseudo-localize its values. English filename.properties becomes filename_en_AA.properties; other languages' filename_la.properties becomes filename_la_AA.properties.

Runs each property value through StringUtil.pseudolocalise(String) from the JBoss Ant-Gettext utilities.

Author:
Jeremy D Monin <jeremy@nand.net>

Constructor Summary
PropsFilePseudoLocalizer()
           
 
Method Summary
static void main(java.lang.String[] args)
          With 1 argument, pseudolocalize that filename's values.
static java.lang.String makePseudoPropFilename(java.lang.String srcPropFilename)
          Make a filename for a pseudo locale properties file.
static void pseudoLocalizeFile(java.io.File srcPropFile, java.lang.String destPropFilename)
          Pseudolocalize a source file to a destination.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropsFilePseudoLocalizer

public PropsFilePseudoLocalizer()
Method Detail

makePseudoPropFilename

public static final java.lang.String makePseudoPropFilename(java.lang.String srcPropFilename)
                                                     throws java.lang.IllegalArgumentException
Make a filename for a pseudo locale properties file.

Parameters:
srcPropFilename - Source filename to localize from, ending with ".properties". English filename.properties becomes filename_en_AA.properties; other languages' filename_la.properties becomes filename_la_AA.properties. Source filename format filename_la_COUNTRY.properties is not supported.
Returns:
The pseudolocalized property file filename from srcPropFilename, see above for details
Throws:
java.lang.IllegalArgumentException - if srcPropFilename contains more than 1 underscore ('_')

pseudoLocalizeFile

public static void pseudoLocalizeFile(java.io.File srcPropFile,
                                      java.lang.String destPropFilename)
                               throws java.io.IOException
Pseudolocalize a source file to a destination. If the destination exists, it will be overwritten.

Parameters:
srcPropFilename - Source file to localize from, filename ending with ".properties"
destPropFilename - Pseudo filename to localize to, from makePseudoPropFilename(String)
Throws:
java.io.IOException - if an error occurs reading or writing the files

main

public static void main(java.lang.String[] args)
With 1 argument, pseudolocalize that filename's values. With 0 or more than 1, print help message.

Return codes:

Parameters:
args - Single filename to pseudolocalize, with same rules as #pseudoLocalizeFile(String)