Interface IFilter
- All Known Implementing Classes:
AbstractFilter,AbstractXmlFilter,AbstractZipFilter,AndroidFilter,CamtasiaWindowsFilter,DocBookFilter,DokuWikiFilter,FlashFilter,HelpAndManualFilter,HHCFilter2,HTMLFilter2,ILIASFilter,InfixFilter,INIFilter,L10nmgrFilter,LatexFilter,MagentoFilter,MoodlePHPFilter,MozillaDTDFilter,MozillaFTLFilter,MozillaLangFilter,MsOfficeFileFilter,OpenDocFilter,OpenDocXMLFilter,OpenXmlFilter,OpenXMLFilter,OpenXMLXMLFilter,PdfFilter,PoFilter,PropertiesFilter,RcFilter,RelaxNGFilter,ResourceBundleFilter,ResXFilter,SbvFilter,SchematronFilter,ScribusFilter,SdlProject,SdlXliff,SrtFilter,SvgFilter,TextFilter,TXMLFilter,Typo3Filter,VisioFilter,WebVttFilter,WiXFilter,WordpressFilter,XHTMLFilter,Xliff1Filter,Xliff2Filter,XLIFFFilter,XMLFilter,XMLSpreadsheetFilter,XtagFilter,YamlFilter
Note: each filter should be stateless, i.e., options shouldn't be stored in filter, but should be sent to filter on each parse, align, or translate operation through context. Filters shouldn't use Core, but use Context.
-
Method Summary
Modifier and TypeMethodDescriptionvoidalignFile(File inFile, File outFile, Map<String, String> config, FilterContext context, IAlignCallback callback) Align a source and translated files.changeOptions(@Nullable Dialog parent, Map<String, String> config) Deprecated.changeOptions(Window parent, Map<String, String> config) Show change options dialog for able to change options.Instance[]The default list of filter instances that this filter class has.Human-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.Returns the encoding of the last parsed source file.booleandefault booleanIndicates whether the filter is bilingual, and thus can be used as external TM (i.e.default booleanIs the filter enabled in default.booleanisFileSupported(File inFile, Map<String, String> config, FilterContext context) Returns whether the file is supported by the filter, given the file and possible file's encoding (nullencoding means autodetect).booleanWhether source encoding can be varied by the user.booleanWhether target encoding can be varied by the user.voidparseFile(File inFile, Map<String, String> config, FilterContext context, IParseCallback callback) Parse single file.voidtranslateFile(File inFile, File outFile, Map<String, String> config, FilterContext context, ITranslateCallback callback) Create translated file.
-
Method Details
-
getFileFormatName
String getFileFormatName()Human-readable name of the File Format this filter supports.- Returns:
- File format name
-
getHint
String 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.- Returns:
- The hint for editing the filter in a non-geek language.
-
getDefaultInstances
Instance[] 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.
- Returns:
- Default filter instances
-
isSourceEncodingVariable
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).
- Returns:
- whether source encoding can be changed by the user
-
isTargetEncodingVariable
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.
- Returns:
- whether target encoding can be changed by the user
-
getFuzzyMark
String getFuzzyMark()Define fuzzy mark prefix for source which will be stored in TM. It's 'fuzzy' by default, but each filter can redefine it.- Returns:
- fuzzy mark prefix
-
isFileSupported
Returns whether the file is supported by the filter, given the file and possible file's encoding (nullencoding means autodetect).For example, DocBook files have .xml extension, as possibly many other XML files, so the filter should check a DTD of the document.
- Parameters:
inFile- Source file.config- filter's configuration optionscontext- processing context- Returns:
- Does the filter support the file.
-
parseFile
void parseFile(File inFile, Map<String, String> config, FilterContext context, IParseCallback callback) throws ExceptionParse single file.- Parameters:
inFile- file to parseconfig- filter's configuration optionscontext- processing contextcallback- callback for parsed data- Throws:
Exception
-
translateFile
void translateFile(File inFile, File outFile, Map<String, String> config, FilterContext context, ITranslateCallback callback) throws ExceptionCreate translated file.- Parameters:
inFile- source fileoutFile- output fileconfig- filter's configuration optionscontext- processing contextcallback- callback for get translation- Throws:
Exception
-
alignFile
void alignFile(File inFile, File outFile, Map<String, String> config, FilterContext context, IAlignCallback callback) throws ExceptionAlign a source and translated files. NB: this is not used for Tools->align files..., but for aligning in console mode- Parameters:
inFile- source fileoutFile- translated fileconfig- filter's configuration optionscontext- processing contextcallback- callback for store aligned data- Throws:
Exception
-
hasOptions
boolean hasOptions() -
changeOptions
@Deprecated @Nullable @Nullable Map<String,String> changeOptions(@Nullable @Nullable Dialog parent, Map<String, String> config) Deprecated.Show change options dialog for able to change options.Deprecated; please use
changeOptions(Window, Map)instead.- Parameters:
parent- parent windowconfig- old options- Returns:
- new options or null if options not changed
-
changeOptions
@Nullable default @Nullable Map<String,String> changeOptions(Window parent, Map<String, String> config) Show change options dialog for able to change options.- Parameters:
parent- parent windowconfig- old options- Returns:
- new options or null if options not changed
-
getInEncodingLastParsedFile
String getInEncodingLastParsedFile()Returns the encoding of the last parsed source file.- Returns:
- the encoding of the last parsed source file, or null when no file has been parsed yet.
-
isBilingual
default boolean isBilingual()Indicates whether the filter is bilingual, and thus can be used as external TM (i.e. files can be added to the /tm/ folder of an OmegaT project). Bilingual filters will supply both source strings and translation strings toIParseCallback.addEntry().- Returns:
trueif the filter is bilingual- Since:
- 4.1.1
-
isEnabledInDefault
default boolean isEnabledInDefault()Is the filter enabled in default.Deprecated filter may be disabled in default. So it can override the method to return false;
- Returns:
- false when the filter is disabled in default.
- Since:
- 5.8.0
-