Home / i18nsanity-pt / i18nsanity-pt-1.0.2
Name Modified Size InfoDownloads / Week
Parent folder
README.txt 2009-07-29 9.6 kB
i18nsanity-pt-1.0.2.tar.gz 2007-10-30 42.7 kB
Totals: 2 Items   52.3 kB 0
i18nsanity
==========

I18nsanity is a set of tools, Ant tasks, Maven 2 plugins, and APIs related to i18n/i10n/internationization/internationalisation including java properties values translation/modification/removal/manipulations/key text replacement.

i18nsanity-pt provides command-line tools, Ant tasks, Maven 2 plugins, and a Java API to work with Java properties files including:

    * Translate - replace text within property values using 1 or more "dictionaries" (properties files that contain texttoreplace=replacementtext type key/value pairs). This is useful in en-gb <-> en-us translation for example
    * Modify - just replace certain property values with others (overlaying Java properties files) using one or more overlay properties files
    * Delete - similar to Modify except that it removes properties with the keys specified in the overlay files
    * Grep - find text within properties keys (supports inverse match and case-insensitive match options)
    * Diff - diff Java properties files regardless of the order of their keys

General Information

Project:
http://sourceforge.net/projects/i18nsanity


History
=======

The i18nsanity project arose out of a need to translate Australian English that was in Atlassian Confluence Java i18n properties files into U.S. English and localize them for the Duke environment.

The main file that contained all of the i18n messages in Confluence (prior to Confluence 2.6.0, this was ConfluenceActionSupport.properties) was huge. We needed to do substring and whole value replacement of properties and most text replacement tools that are out there only replace text throughout the file, unless you are good enough with regular expressions, Perl, etc. to be able to only change text after the first "=" in every line.

By using the i18nsanity-pt tool I wrote, you can easily translate and localize files using the translate class (via command-line with supplied example scripts or Ant task or Maven 2 plugin) by just creating "dictionary" properties files that define the substring replacements. These dictionary files can even be layered and applied in any order you want, so that you can easily separate out the categories of Java properties replacement you need. The format of the file is:

substringtoreplace=newsubstring
...



In addition to "translate" (Java properties value substring replacement), there are commands/Ant tasks/Maven 2 mojos to completely override Java properties values:

keytooverride=newvalue
...


remove Java properties (searching by exact key name):

keytoremove=
...


a tool to diff Java properties values that doesn't care about the order of the keys in the properties file and even a tool to grep the values of Java properties files (which supports case-insensitive and inverse matches (values NOT containing some string).

Finally, you can run a "translate" on a Java properties file with an empty dictionary file (an empty text file) and you can automatically sort the Java properties files alphabetically by key.

Thanks for checking out i18nsanity, and please let me know if you have any questions or issues.

Also, let me know if you'd like to contribute!

Gary S. Weaver


How to Use
==========

How to Define i18sanity-pt Config Properties Files
--------------------------------------------------

translate_properties_example.properties
(Example translation properties to translate en_GB to en_US)
---file start---
# Substring replacements for values within properties file

olour=olor
ustomise=ustomize
ummarise=ummarize
avourite=avorite
icence=icense
rganise=rganize
isation=ization
ptimise=ptimize
atalogue=atalog
entre=enter
Grey=Gray
grey=gray
onour=onor
ractise=ractice
rogramme=rogram
peciality=pecialty
efence=efense
outeing=outing
hilst=hile
ehaviour=ehavior
---file end---

remove-properties-example.properties
---file start---
# Keys of properties to remove
 
contact.administrators=
bug.feature.request=
url.bug.feature.request=
---file end---

add-or-modify-properties-example.properties
---file start---
# Keys of properties that will be added/modified
 
powered.by.atlassian.confluence=Need Help? Contact the Help Desk at 123-456-7890 - (Version: {0} Build:#{1} {2})
public.signup.disabled=The wiki is not set up to permit public signup. Please contact the <a href="{0}">site administrators</a> for more information.
action.manage.users.groups=Manage Users/Groups
dont.see.spaces.heading=Can''t find a space you''re looking for?
dont.see.spaces.desc=Log in using the link in the upper righthand corner to see all of the spaces to which you have access.
space.request.info=To request a space, and learn more about the wiki, please visit the Space Request page in the Wiki Help space.
successful.logout.message=To completely log out of the wiki please close or quit your browser.
---file end---


How to Use i18sanity-pt Command-Line Utilities
----------------------------------------------

Note: Currently only bash scripts are available (*nix and OS X command line)

    * Download i18nsanity-pt
    * Expand the tar.gz and put the directory somewhere nice and permanent
    * Put the (i18nsanity dir)/bin/ dir on your path
    * Call one of the scripts in that bin directory. (Usage information is presented at command-line.)


How to Use the i18sanity-pt Maven 2 Plugin
------------------------------------------

Note: I'm currently working on getting the plugin into some public repository so it is easier to use.

Here is information on how to use if you can build/deploy locally for now:

Under build, plugins:

            <plugin>
                <groupId>net.sf.i18nsanity</groupId>
                <artifactId>i18nsanity-pt</artifactId>
                <version>1.0.2</version>
                <executions>
                    <execution>
                        <id>replace_properties</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>modifyProperties</goal>
                        </goals>
                        <configuration>
                            <inputFile>some/path/to/file.properties</inputFile>
                            <outputFile>some/path/to/file.properties</outputFile>
                            <propsToReplaceFiles>
                                <propsToReplaceFile>config/properties_to_replace.properties</propsToReplaceFile>
                            </propsToReplaceFiles>
                        </configuration>
                    </execution>
 
                    <execution>
                        <id>remove_properties</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>removeProperties</goal>
                        </goals>
                        <configuration>
                            <inputFile>some/path/to/file.properties</inputFile>
                            <outputFile>some/path/to/file.properties</outputFile>
                            <propsToDeleteFiles>
                                <propsToDeleteFile>config/keys_to_remove.properties</propsToDeleteFile>
                            </propsToDeleteFiles>
                        </configuration>
                    </execution>
 
                    <execution>
                        <id>substring_replace_values_in_properties</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>translateProperties</goal>
                        </goals>
                        <configuration>
                            <inputFile>some/path/to/file.properties</inputFile>
                            <outputFile>some/path/to/file.properties</outputFile>
                            <dictionaryFiles>
                                <dictionaryFile>config/value_substrings_to_replace1.properties</dictionaryFile>
                                <dictionaryFile>config/value_substrings_to_replace2.properties</dictionaryFile>
                            </dictionaryFiles>
                        </configuration>
                    </execution>
                </executions>
 
            </plugin>


Developing i18nsanity
=====================

Directions for Compiling Using Maven 2
--------------------------------------

Quick start:

1) If you haven't already, download and install maven 2 from http://maven.apache.org/download.html and make sure your MAVEN_HOME and PATH are set as in the maven install documentation on their site.

2) To build, and install to your local repository, use the following command:

mvn clean install

note: if tests are failing, you may need to skip them to build the plugin. If so, use:

mvn -Dmaven.test.skip=true clean install


Command-line Usage
------------------

For command-line usage, trying calling the scripts in bin/ if you can use bash. If you want to contribute the batch files, etc. to get it to work in your environment, you are more than welcome!


Development
-----------

Please contact us to help, but if you just want to take a look and don't know Maven 2...

To generate an IDea project:

mvn idea:idea

To generate an Eclipse project:

mvn eclipse:eclipse

To build in Netbeans:

mvn netbeans-freeform:generate-netbeans-project

or try the nbm plugin or Mevenide Netbeans for Maven 2 at http://mevenide.codehaus.org/m2-site/index.html

Thanks!
Gary
Source: README.txt, updated 2009-07-29