Class AbstractFilter
- All Implemented Interfaces:
IFilter
- Direct Known Subclasses:
AbstractXmlFilter,AbstractZipFilter,DokuWikiFilter,HTMLFilter2,ILIASFilter,INIFilter,LatexFilter,MagentoFilter,MoodlePHPFilter,MozillaDTDFilter,MozillaFTLFilter,MozillaLangFilter,OpenDocFilter,OpenXMLFilter,PdfFilter,PoFilter,RcFilter,ResourceBundleFilter,SrtFilter,TextFilter,XMLFilter,XtagFilter,YamlFilter
The process how the filter works is the following:
- Source text is extracted.
- Tags are converted into shortcuts and these shortcuts are temporarily stored
- Source text with shortened tags is sent to OmegaT core
- Core returns a translation (or the same text if there's no translation)
- Tags shortcuts are expanded in translated text
- Translated text is written into the output file
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThis value represents to the user that the encoding is determined by the filter itself.static final StringThe default output filename pattern.static final StringThe original file extension.static final Stringstatic final StringFile properties.static final Stringstatic final StringThe original filename (with extension).static final StringThe original filename without extension.static final Stringstatic final Stringstatic final StringWorkstation properties.static final Stringstatic final Stringstatic final Stringcountry "YY" onlystatic final StringOld spelling of the variable for country "YY" onlystatic final Stringlanguage "XX" onlystatic final String"XX-YY", the TMX/XML language codestatic final String"xx_YY", locale codestatic final StringMicrosoft.static final StringSystem time at generation time in various patterns.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidalignFile(File inFile, File outFile, @Nullable Map<String, String> config, FilterContext fc, IAlignCallback callback) Align a source and translated files.changeOptions(@Nullable Dialog parent, Map<String, String> config) Deprecated.abstract Instance[]The default list of filter instances that this filter class has.abstract StringHuman-readable name of the File Format this filter supports.Define fuzzy mark prefix for source which will be stored in TM.getHint()Returns the hint displayed while the user edits the filter, and when she adds/edits the instance of this filter.@Nullable StringReturns the encoding of the last parsed source file.booleanOmegaT calls this to see whether the filter has any options.booleanisFileSupported(File inFile, Map<String, String> config, FilterContext fc) Returns whether the file is supported by the filter, given the file and possible file's encoding (nullencoding means autodetect).abstract booleanWhether source encoding can be varied by the user.abstract booleanWhether target encoding can be varied by the user.final voidparseFile(File inFile, @Nullable Map<String, String> config, FilterContext fc, IParseCallback callback) Parse single file.voidsetCallbacks(@Nullable IParseCallback parseCallback, @Nullable ITranslateCallback translateCallback) Set both callbacks.final voidtranslateFile(File inFile, File outFile, Map<String, String> config, FilterContext fc, ITranslateCallback callback) Create translated file.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.omegat.filters2.IFilter
changeOptions, isBilingual, isEnabledInDefault
-
Field Details
-
ENCODING_AUTO_HUMAN
This value represents to the user that the encoding is determined by the filter itself. "In code" thenullis used to represent automatic encoding selection. -
TFP_FILENAME
The original filename (with extension).- See Also:
-
TFP_NAMEONLY
The original filename without extension.- See Also:
-
TFP_EXTENSION
The original file extension.- See Also:
-
TFP_TARGET_LOCALE
"xx_YY", locale code- See Also:
-
TFP_TARGET_LANGUAGE
"XX-YY", the TMX/XML language code- See Also:
-
TFP_TARGET_LANG_CODE
language "XX" only- See Also:
-
TFP_TARGET_COUNTRY_CODE
country "YY" only- See Also:
-
TFP_TARGET_COUTRY_CODE
Old spelling of the variable for country "YY" only- See Also:
-
TFP_TIMESTAMP_LA
System time at generation time in various patterns.- See Also:
-
TFP_TIMESTAMP_LD
- See Also:
-
TFP_TIMESTAMP_LDD
- See Also:
-
TFP_TIMESTAMP_LH
- See Also:
-
TFP_TIMESTAMP_LHH
- See Also:
-
TFP_TIMESTAMP_LM
- See Also:
-
TFP_TIMESTAMP_LMM
- See Also:
-
TFP_TIMESTAMP_LS
- See Also:
-
TFP_TIMESTAMP_LSS
- See Also:
-
TFP_TIMESTAMP_LYYYY
- See Also:
-
TFP_TIMESTAMP_UD
- See Also:
-
TFP_TIMESTAMP_UEEE
- See Also:
-
TFP_TIMESTAMP_UEEEE
- See Also:
-
TFP_TIMESTAMP_UH
- See Also:
-
TFP_TIMESTAMP_UHH
- See Also:
-
TFP_TIMESTAMP_UM
- See Also:
-
TFP_TIMESTAMP_UMM
- See Also:
-
TFP_TIMESTAMP_UMMM
- See Also:
-
TFP_SYSTEM_OS_NAME
Workstation properties.- See Also:
-
TFP_SYSTEM_OS_VERSION
- See Also:
-
TFP_SYSTEM_OS_ARCH
- See Also:
-
TFP_SYSTEM_USER_NAME
- See Also:
-
TFP_SYSTEM_HOST_NAME
- See Also:
-
TFP_FILE_SOURCE_ENCODING
File properties.- See Also:
-
TFP_FILE_TARGET_ENCODING
- See Also:
-
TFP_FILE_FILTER_NAME
- See Also:
-
TFP_TARGET_LOCALE_LCID
Microsoft.- See Also:
-
TARGET_DEFAULT
The default output filename pattern.It is equal to "${filename}", which means that the name of the translated file should be the same as the name of the input file.
- See Also:
-
-
Constructor Details
-
AbstractFilter
public AbstractFilter()
-
-
Method Details
-
getTargetFilenamePatterns
-
getFileFormatName
Human-readable name of the File Format this filter supports.- Specified by:
getFileFormatNamein interfaceIFilter- Returns:
- File format name
-
getDefaultInstances
The default list of filter instances that this filter class has. One filter class may have different filter instances, different by source file mask, encoding of the source file etc.Note that the user may change the instances freely.
- Specified by:
getDefaultInstancesin interfaceIFilter- Returns:
- Default filter instances
-
isSourceEncodingVariable
public abstract boolean isSourceEncodingVariable()Whether source encoding can be varied by the user.True means that OmegaT should handle all the encoding mess.
Return false to state that your filter doesn't need encoding management provided by OmegaT, because it either autodetect the encoding based on file contents (like HTML filter does) or the encoding is fixed (like in OpenOffice files).
- Specified by:
isSourceEncodingVariablein interfaceIFilter- Returns:
- whether source encoding can be changed by the user
-
isTargetEncodingVariable
public abstract boolean isTargetEncodingVariable()Whether target encoding can be varied by the user.True means that OmegaT should handle all the encoding mess.
Return false to state that your filter doesn't need encoding management provided by OmegaT, because the encoding is fixed (like in OpenOffice files), or for some other reason.
- Specified by:
isTargetEncodingVariablein interfaceIFilter- Returns:
- whether target encoding can be changed by the user
-
isFileSupported
Returns whether the file is supported by the filter, given the file and possible file's encoding (nullencoding means autodetect). Default implementation creates a reader and callsisFileSupported(BufferedReader). You should override only one of the two.For example, DocBook files have .xml extension, as possibly many other XML files, so the filter should check a DTD of the document.
- Specified by:
isFileSupportedin interfaceIFilter- Parameters:
inFile- Source file.fc- Filter context.config- filter's configuration options- Returns:
- Does the filter support the file.
-
getFuzzyMark
Define fuzzy mark prefix for source which will be stored in TM. It's 'fuzzy' by default, but each filter can redefine it.- Specified by:
getFuzzyMarkin interfaceIFilter- Returns:
- fuzzy mark prefix
-
getHint
Returns the hint displayed while the user edits the filter, and when she adds/edits the instance of this filter. The hint may be any string, preferably in a non-geek language. -
hasOptions
public boolean hasOptions()OmegaT calls this to see whether the filter has any options. By default, returns false, so filter authors should override this to tell OmegaT core that this filter has options.- Specified by:
hasOptionsin interfaceIFilter- Returns:
- True if the filter has any options, and false otherwise.
-
changeOptions
@Deprecated public @Nullable Map<String,String> changeOptions(@Nullable Dialog parent, Map<String, String> config) Deprecated.Description copied from interface:IFilterShow change options dialog for able to change options.Deprecated; please use
IFilter.changeOptions(Window, Map)instead.- Specified by:
changeOptionsin interfaceIFilter- Parameters:
parent- parent windowconfig- old options- Returns:
- new options or null if options not changed
-
parseFile
public final void parseFile(File inFile, @Nullable Map<String, String> config, FilterContext fc, IParseCallback callback) throws ExceptionDescription copied from interface:IFilterParse single file. -
alignFile
public final void alignFile(File inFile, File outFile, @Nullable Map<String, String> config, FilterContext fc, IAlignCallback callback) throws ExceptionDescription copied from interface:IFilterAlign a source and translated files. NB: this is not used for Tools->align files..., but for aligning in console mode -
translateFile
public final void translateFile(File inFile, File outFile, Map<String, String> config, FilterContext fc, ITranslateCallback callback) throws ExceptionDescription copied from interface:IFilterCreate translated file.- Specified by:
translateFilein interfaceIFilter- Parameters:
inFile- source fileoutFile- output fileconfig- filter's configuration optionsfc- processing contextcallback- callback for get translation- Throws:
Exception
-
setCallbacks
public void setCallbacks(@Nullable IParseCallback parseCallback, @Nullable ITranslateCallback translateCallback) Set both callbacks. Used for child XML filters only. -
getInEncodingLastParsedFile
Description copied from interface:IFilterReturns the encoding of the last parsed source file.- Specified by:
getInEncodingLastParsedFilein interfaceIFilter- Returns:
- the encoding of the last parsed source file, or null when no file has been parsed yet.
-