file2xliff4j
Class PlaintextImporter

java.lang.Object
  extended by file2xliff4j.PlaintextImporter
All Implemented Interfaces:
Converter

public class PlaintextImporter
extends java.lang.Object
implements Converter

The PlaintextImporter identifies translatable text in plaintext files, creating an XLIFF file with source elements containing segments of the text. (The XLIFF spec defines plaintext as having "no formatting other than, possibly, wrapping.")

Because plaintext has no formatting other than wrapping, the resulting XLIFF source elements will include no bx, ex, or x tags; no format file will be needed to map bx/ex/x tags back to their original formatting.

Author:
Weldon Whipple <weldon@whipple.org>

Field Summary
 
Fields inherited from interface file2xliff4j.Converter
BLKSIZE, formatSuffix, skeletonSuffix, startXliff, stylesTSkeletonSuffix, tSkeletonSuffix, xliffSuffix, xmlDeclaration
 
Constructor Summary
PlaintextImporter()
          Constructor for the Plaintext importer.
 
Method Summary
 ConversionStatus convert(ConversionMode mode, java.util.Locale language, java.lang.String phaseName, int maxPhase, java.nio.charset.Charset nativeEncoding, FileType nativeFileType, java.lang.String inputMifFileName, java.lang.String baseDir, Notifier notifier)
          Deprecated. 
 ConversionStatus convert(ConversionMode mode, java.util.Locale language, java.lang.String phaseName, int maxPhase, java.nio.charset.Charset nativeEncoding, FileType nativeFileType, java.lang.String inputFileName, java.lang.String baseDir, Notifier notifier, SegmentBoundary boundary, java.io.StringWriter generatedFileName)
          Convert a plaintext file to XLIFF.
 ConversionStatus convert(ConversionMode mode, java.util.Locale language, java.lang.String phaseName, int maxPhase, java.nio.charset.Charset nativeEncoding, FileType nativeFileType, java.lang.String inputMifFileName, java.lang.String baseDir, Notifier notifier, SegmentBoundary boundary, java.io.StringWriter generatedFileName, java.util.Set<f2xutils.XMLTuXPath> skipList)
          Convert a Maker Interchange Format file (MIF) to XLIFF.
 java.lang.Object getConversionProperty(java.lang.String property)
          Return an object representing a format-specific (and converter-specific) property.
 FileType getFileType()
          Return the file type that this converter handles.
 void setConversionProperty(java.lang.String property, java.lang.Object value)
          Set a format-specific property that might affect the way that the conversion occurs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PlaintextImporter

public PlaintextImporter()
Constructor for the Plaintext importer.

Method Detail

convert

public ConversionStatus convert(ConversionMode mode,
                                java.util.Locale language,
                                java.lang.String phaseName,
                                int maxPhase,
                                java.nio.charset.Charset nativeEncoding,
                                FileType nativeFileType,
                                java.lang.String inputFileName,
                                java.lang.String baseDir,
                                Notifier notifier,
                                SegmentBoundary boundary,
                                java.io.StringWriter generatedFileName)
                         throws ConversionException
Convert a plaintext file to XLIFF. In the process, generate a skeleton file to be used in generating a translated version of the original file, following translation.

Specified by:
convert in interface Converter
Parameters:
mode - The mode of conversion (to or from XLIFF). The value must be TO_XLIFF.
language - The primary language of the plaintext file to be imported.
phaseName - The target phase-name. This value is ignored by importers.
maxPhase - The maximum phase number. This value is ignored by importers.
nativeEncoding - The encoding of the input plaintext file. If this argument is null, the importer will make the following "guesses," based on primary language:
English:
ISO-8859-1
Danish, Dutch, Finnish, French, German, Icelandic, Italian, Norwegian, Portuguese, Spanish, Swedish:
ISO-8859-1
All other languages:
UTF-8
nativeFileType - The type of the input file. This value is ignored. (The value "plaintext" is an official XLIFF attribute value and is used unconditionally by this importer.)
inputFileName - The name of the plaintext input file.
baseDir - The directory that contains the input file--from which we will read input. This is also the directory to which the output XLIFF and skeleton files will be written. The output files will be named as follows:
  • <original_file_name>.xliff
  • <original_file_name>.skeleton
notifier - Instance of a class that implements the Notifier interface (to send notifications in case of conversion error).
boundary - The boundary on which to segment translation units (e.g., on paragraph or sentence boundaries). If null, sentence boundaries are used.
generatedFileName - If non-null, the converter will write the name of the file (without parent directories) to which the generated XLIFF file was written.
Returns:
Indicator of the status of the conversion.
Throws:
ConversionException - If a conversion exception is encountered.

convert

public ConversionStatus convert(ConversionMode mode,
                                java.util.Locale language,
                                java.lang.String phaseName,
                                int maxPhase,
                                java.nio.charset.Charset nativeEncoding,
                                FileType nativeFileType,
                                java.lang.String inputMifFileName,
                                java.lang.String baseDir,
                                Notifier notifier,
                                SegmentBoundary boundary,
                                java.io.StringWriter generatedFileName,
                                java.util.Set<f2xutils.XMLTuXPath> skipList)
                         throws ConversionException
Convert a Maker Interchange Format file (MIF) to XLIFF. Additionally create skeleton and format files. (The skeleton and format files are used on export to generate localized MIF files from seleced XLIFF targets.)

Specified by:
convert in interface Converter
Parameters:
mode - The mode of conversion (to or from XLIFF). The value must be TO_XLIFF.
language - The primary language of the MIF file to be imported.
phaseName - The target phase-name. This value is ignored.
maxPhase - The maximum phase number. This value is ignored.
nativeEncoding - The encoding of the input MIF. (MIF files are FrameMaker documents encoded in ASCII format. On Unix, ISO Latin-1 is used. MIF can also use Shift-JIS or EUC (Japanese), Big5, CNS or GB2312-80.EUC (Chinese), or KSC5601-1992 for Korean.)
nativeFileType - The type of the input file. This value is ignored. (The value "mif" is an official XLIFF attribute value and is used unconditionally by this importer.)
inputMifFileName - The name of the input MIF file.
baseDir - The directory that contains the input MIF file--from which we will read the input file. This is also the directory in which the output xliff, skeleton and format files will be written. The output files will be named as follows:
  • <original_file_name>.xliff
  • <original_file_name>.skeleton
  • <original_file_name>.format
notifier - Instance of a class that implements the Notifier interface (to send notifications in case of conversion error).
boundary - The boundary on which to segment translation units (e.g., on paragraph or sentence boundaries)
generatedFileName - If non-null, the converter will write the name of the file (without parent directories) to which the generated XLIFF file was written.
skipList - (Not used by this converter.)
Returns:
Indicator of the status of the conversion.
Throws:
ConversionException - If a conversion exception is encountered.

convert

@Deprecated
public ConversionStatus convert(ConversionMode mode,
                                           java.util.Locale language,
                                           java.lang.String phaseName,
                                           int maxPhase,
                                           java.nio.charset.Charset nativeEncoding,
                                           FileType nativeFileType,
                                           java.lang.String inputMifFileName,
                                           java.lang.String baseDir,
                                           Notifier notifier)
                         throws ConversionException
Deprecated. 

Convert a Maker Interchange Format file (MIF) to XLIFF. Additionally create skeleton and format files. (The skeleton and format files are used on export to generate localized MIF files from seleced XLIFF targets.)

Specified by:
convert in interface Converter
Parameters:
mode - The mode of conversion (to or from XLIFF). The value must be TO_XLIFF.
language - The primary language of the MIF file to be imported.
phaseName - The target phase-name. This value is ignored.
maxPhase - The maximum phase number. This value is ignored.
nativeEncoding - The encoding of the input MIF. (MIF files are FrameMaker documents encoded in ASCII format. On Unix, ISO Latin-1 is used. MIF can also use Shift-JIS or EUC (Japanese), Big5, CNS or GB2312-80.EUC (Chinese), or KSC5601-1992 for Korean.)
nativeFileType - The type of the input file. This value is ignored. (The value "mif" is an official XLIFF attribute value and is used unconditionally by this importer.)
inputMifFileName - The name of the input MIF file.
baseDir - The directory that contains the input MIF file--from which we will read the input file. This is also the directory in which the output xliff, skeleton and format files will be written. The output files will be named as follows:
  • <original_file_name>.xliff
  • <original_file_name>.skeleton
  • <original_file_name>.format
notifier - Instance of a class that implements the Notifier interface (to send notifications in case of conversion error).
Returns:
Indicator of the status of the conversion.
Throws:
ConversionException - If a conversion exception is encountered.

getConversionProperty

public java.lang.Object getConversionProperty(java.lang.String property)
Return an object representing a format-specific (and converter-specific) property.

Specified by:
getConversionProperty in interface Converter
Parameters:
property - The name of the property to return.
Returns:
An Object that represents the property's value.

getFileType

public FileType getFileType()
Return the file type that this converter handles. (For importers, this means the file type that it imports to XLIFF; for exporters, it is the file type that ie exports to (from XLIFF).

Specified by:
getFileType in interface Converter
Returns:
the PLAINTEXT file type.

setConversionProperty

public void setConversionProperty(java.lang.String property,
                                  java.lang.Object value)
                           throws ConversionException
Set a format-specific property that might affect the way that the conversion occurs.

Note: This converter needs no format-specific properties. If any are passed, they will be silently ignored.

Specified by:
setConversionProperty in interface Converter
Parameters:
property - The name of the property
value - The value of the property
Throws:
ConversionException - If the property isn't recognized (and if it matters).