All Packages Class Hierarchy This Package Previous Next Index
Class Samples.GetQuotes
java.lang.Object
|
+----Samples.GetQuotes
- public class GetQuotes
- extends Object
This class provides a utility to make java source i18n compliant.
Note the translated file is not ready to compile until the
developer has provided for resource bundle loading and access.
For examples, see the Java Internationalization documentation.
-
excludeCount
-
-
excludes
-
-
keyDifferentiator
-
-
keys
-
-
MaxQuote
-
-
outputDirectory
-
-
quoteCount
-
-
quotes
-
-
resBundleName
-
-
GetQuotes(String, boolean)
- Create an instance of GetQuotes.
-
getSub(String)
- Gets the substition key string for the original string.
-
isExclude(String)
- Checks if the string is to be excluded from translation.
-
loadExcludes(String)
- Loads the file of excluded strings.
-
main(String[])
- Runs GetQuotes accepting command args and performing GetQuotes invocation.
-
makeKey(String)
- Turns a quote string into an acceptable key.
-
parseStream(boolean, StreamTokenizer, FileOutputStream)
- Parses the source code substituting keys for quoted strings.
-
restored(String)
- Translates special control characters into escape character sequences.
quoteCount
static int quoteCount
keyDifferentiator
static int keyDifferentiator
MaxQuote
static int MaxQuote
excludeCount
static int excludeCount
quotes
static String quotes[]
keys
static String keys[]
excludes
static String excludes[]
outputDirectory
static String outputDirectory
resBundleName
static String resBundleName
GetQuotes
GetQuotes(String name,
boolean output)
- Create an instance of GetQuotes.
Load files and initiate the parsing/translation operation.
- Parameters:
- name - the file or directory name
- output - a flag indicating the translated file is to be sent to stdout
main
public static void main(String args[])
- Runs GetQuotes accepting command args and performing GetQuotes invocation.
Examples:
To generate a table to stdout, with no translated file,
Samples.GetQuotes ..\Samples\BuildAccessorWindow.java -h"American English" -t
To generate a translation to stdout,
Samples.GetQuotes ..\Samples\BuildAccessorWindow.java -bMyResources -o
To generate translated files from the Samples directory to Samples/I18n,
with a locale file captured in a file from stdout, using a string
excludes file and a specific resource bundle name,
Samples.GetQuotes ..\Samples -h"American English" -xsamplesExclude.txt -t -d..\Samples\I18n -bMyResources > locale_en_US.properties
- Parameters:
- args - list of command line arguments
parseStream
void parseStream(boolean outputFlag,
StreamTokenizer stis,
FileOutputStream fos)
- Parses the source code substituting keys for quoted strings.
- Parameters:
- outputFlag - if true send parsed and translated text to stdout
- stis - a StreamTokenizer to handle the source code parsing
- fos - an output stream to write parsed source and translations.
getSub
String getSub(String originalQuote)
- Gets the substition key string for the original string. If the
string does not exist in the database of strings, store it and
create a key for it. If the original quote is found in a list of
quotes to exclude the original quote is returned. Translated
keys are returned with the resource bundle accessor method syntax.
- Parameters:
- originalQuote - the content of a quoted string found in the source code
- Returns:
- if translated, the key to the string, else the original string
makeKey
String makeKey(String quote)
- Turns a quote string into an acceptable key.
The key and the quote are ultimately stored in the locale file.
Keys are generated by taking the first words of the quote, special
characters are excluded, capitalizing the words, concatenating
the words together, truncating the words at a certain length, then
adding a number to make the key unique if necessary.
If a quote does not have the requisite words to form a key, a special
key is generated for the quote.
- Parameters:
- quote - the quote taken from the source code
- Returns:
- the new key for the quote
loadExcludes
static void loadExcludes(String filename)
- Loads the file of excluded strings.
- Parameters:
- filename - the name of the file containing the excluded strings.
isExclude
boolean isExclude(String quote)
- Checks if the string is to be excluded from translation.
- Parameters:
- quote - a quoted string from the source code
- Returns:
- true if found on the excludes list else false
restored
private String restored(String quote)
- Translates special control characters into escape character sequences.
- Parameters:
- quote - a string possibly containing special control characters
- Returns:
- the quote with any control characters converted to escape sequences
All Packages Class Hierarchy This Package Previous Next Index