Table of Contents | ||
---|---|---|
|
messageUtils.pl
Overview
messageUtils.pl is a simple perl script which that can be helpful in managing messages.properties files. It provides two basic features:
- Searches for unused message codes within a project/module/etc.
- Compares messages.properties files from different locales for missing message codes
The script can be found here: http://sourcesvn.openmrs.org/browse/openmrs-contrib/utilities/messageUtils/
Disclaimer: This script has only been used on a single module to date , and is not foolproof. The script writes all its changes to a separate output file, and I recommend reviewing the outputs before replacing any existing .properties files. Also, make sure to read the limitations of the script as documented below.
...
To find unused message codes, run messageUtils with the following parameters:
Code Block |
---|
messageUtils.pl -s [MESSAGE_FILE] [TARGET_DIRECTORY] [OUTPUT_FILE]
|
The script with will load in all the message codes in the message file and search for references to each code in all files in the target directory (and subdirectories, excluding existing .properties files). The output file will contain all the message codes in the message file, except that all codes that weren't found in the target directory will be moved to the end of the file, after a comment line "NOT FOUND". The user can then manually triage this list and remove the unused codes.
...
To compare the message codes in two files from different locales, run messageUtils with the following parameters:
Code Block |
---|
messagesUtils.pl -c [MESSAGE_FILE] [TARGET_FILE] [OUTPUT_FILE]
|
...
messages.properties:
Code Block |
---|
general.man=Man
general.woman=Woman
general.hot=Hot
general.cold=Cold
|
messages_es.properties:
Code Block |
---|
general.hot=Caliente
general.man=Senior
|
Running "messageUtils.pl -c messages.properties messages_es.properties messages_es_output.properties" will result in the creation of the following output file:
Code Block |
---|
general.man=Senior
general.hot=Caliente
<!--NOT FOUND-->
general.woman=Woman
general.cold=Cold
|
...
- Scans a specified message bundle (defaults to main message.properties bundle) and source code, listing out both unused message codes (in bundle, not in code) and missing message codes (in code, but not in message bundle).
Download here.The script can be found here: http://svn.openmrs.org/openmrs-contrib/utilities/messageUtils/
Usage
No Format |
---|
usage: Usage: messageUtils.groovy [options] /path/to/folder/with/messages/ /path/to/openmrs/source/ -h,--help Show this help information -l,--locale <locale> Specify locale for messages to be scanned -m,--missing-only Only list missing message codes (used in source, but not defined) -s,--summary Show summary stats -u,--unused-only Only list unused message codes (defined, but never used in source) |
...