Package org.omegat.filters3.xml
Class XMLFilter
java.lang.Object
org.omegat.filters2.AbstractFilter
org.omegat.filters3.xml.XMLFilter
- All Implemented Interfaces:
IFilter,Translator
- Direct Known Subclasses:
AndroidFilter,CamtasiaWindowsFilter,DocBookFilter,FlashFilter,HelpAndManualFilter,InfixFilter,L10nmgrFilter,OpenDocXMLFilter,OpenXMLXMLFilter,PropertiesFilter,RelaxNGFilter,ResXFilter,SchematronFilter,ScribusFilter,SvgFilter,TXMLFilter,Typo3Filter,VisioFilter,WiXFilter,WordpressFilter,XHTMLFilter,XLIFFFilter,XMLSpreadsheetFilter
Abstract basis filter for XML format filters: OpenDocument, DocBook etc.
Ideally should allow creation of a new XML dialect filter by simply
specifying translatable tags and attributes.
-
Field Summary
Fields inherited from class org.omegat.filters2.AbstractFilter
ENCODING_AUTO_HUMAN, TARGET_DEFAULT, TFP_EXTENSION, TFP_FILE_FILTER_NAME, TFP_FILE_SOURCE_ENCODING, TFP_FILE_TARGET_ENCODING, TFP_FILENAME, TFP_NAMEONLY, TFP_SYSTEM_HOST_NAME, TFP_SYSTEM_OS_ARCH, TFP_SYSTEM_OS_NAME, TFP_SYSTEM_OS_VERSION, TFP_SYSTEM_USER_NAME, TFP_TARGET_COUNTRY_CODE, TFP_TARGET_COUTRY_CODE, TFP_TARGET_LANG_CODE, TFP_TARGET_LANGUAGE, TFP_TARGET_LOCALE, TFP_TARGET_LOCALE_LCID, TFP_TIMESTAMP_LA, TFP_TIMESTAMP_LD, TFP_TIMESTAMP_LDD, TFP_TIMESTAMP_LH, TFP_TIMESTAMP_LHH, TFP_TIMESTAMP_LM, TFP_TIMESTAMP_LMM, TFP_TIMESTAMP_LS, TFP_TIMESTAMP_LSS, TFP_TIMESTAMP_LYYYY, TFP_TIMESTAMP_UD, TFP_TIMESTAMP_UEEE, TFP_TIMESTAMP_UEEEE, TFP_TIMESTAMP_UH, TFP_TIMESTAMP_UHH, TFP_TIMESTAMP_UM, TFP_TIMESTAMP_UMM, TFP_TIMESTAMP_UMMM -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidProcess comment.createReader(File inFile, String inEncoding) Creates a special XML-encoding-aware reader of an input file.createWriter(@Nullable File outFile, @Nullable String outEncoding) Creates a writer of the translated file.Gives the dialect@Nullable Language@Nullable LanguagebooleanisFileSupported(BufferedReader reader) Returns whether the XML file is supported by the filter.booleanReturns true if the current section should be ignored by parser.booleanWhether source encoding can be varied by the user.booleanTarget encoding can be varied by the user.voidprocessFile(File inFile, @Nullable File outFile, FilterContext fc) Processes an XML file.voidFinish tag translation.voidtagStart(String path, @Nullable Attributes atts) Start tag translation.voidProcess text.translate(String entry, @Nullable List<ProtectedPart> protectedParts) The method the Handler would call to pass translatable content to OmegaT core and receive translation.Methods inherited from class org.omegat.filters2.AbstractFilter
alignFile, changeOptions, getDefaultInstances, getFileFormatName, getFuzzyMark, getHint, getInEncodingLastParsedFile, getTargetFilenamePatterns, hasOptions, isFileSupported, parseFile, setCallbacks, translateFileMethods 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
-
Constructor Details
-
XMLFilter
Creates a new instance of XMLFilter
-
-
Method Details
-
getDialect
Gives the dialect -
createReader
Creates a special XML-encoding-aware reader of an input file.- Specified by:
createReaderin interfaceTranslator- Parameters:
inFile- The source file.inEncoding- Encoding of the source file, if the filter supports it. Otherwise, it should be null.- Returns:
- The reader of the source file.
- Throws:
UnsupportedEncodingException- Thrown if JVM doesn't support the specified inEncoding.IOException- If any I/O Error occurs upon reader creation.
-
createWriter
public BufferedWriter createWriter(@Nullable File outFile, @Nullable String outEncoding) throws UnsupportedEncodingException, IOException Creates a writer of the translated file. Acceptsnulloutput file -- returns a writer to/dev/nullin this case ;-)- Specified by:
createWriterin interfaceTranslator- Parameters:
outFile- The target file.outEncoding- Encoding of the target file, if the filter supports it. Otherwise, null.- Returns:
- The writer for the target file.
- Throws:
UnsupportedEncodingException- Thrown if JVM doesn't support the specified outEncodingIOException- If any I/O Error occurs upon writer creation
-
getTargetLanguage
- Specified by:
getTargetLanguagein interfaceTranslator- Returns:
- The target language of the project
-
getSourceLanguage
- Specified by:
getSourceLanguagein interfaceTranslator- Returns:
- The source language of the project
-
processFile
public void processFile(File inFile, @Nullable File outFile, FilterContext fc) throws IOException, TranslationException Processes an XML file.- Throws:
IOExceptionTranslationException
-
isSourceEncodingVariable
public boolean isSourceEncodingVariable()Whether source encoding can be varied by the user. If XML file has no encoding declaration, UTF-8 will be used, hence returnsfalseby default.- Specified by:
isSourceEncodingVariablein interfaceIFilter- Specified by:
isSourceEncodingVariablein classAbstractFilter- Returns:
false
-
isTargetEncodingVariable
public boolean isTargetEncodingVariable()Target encoding can be varied by the user.- Specified by:
isTargetEncodingVariablein interfaceIFilter- Specified by:
isTargetEncodingVariablein classAbstractFilter- Returns:
true
-
translate
The method the Handler would call to pass translatable content to OmegaT core and receive translation.- Specified by:
translatein interfaceTranslator
-
isFileSupported
Returns whether the XML file is supported by the filter.
ReadsOConsts.READ_AHEAD_LIMITand tries to detect constrained text and match constraints defined inXMLDialectagainst them. -
tagStart
Description copied from interface:TranslatorStart tag translation.- Specified by:
tagStartin interfaceTranslator- Parameters:
path- path in the XMLatts- attributes
-
tagEnd
Description copied from interface:TranslatorFinish tag translation.- Specified by:
tagEndin interfaceTranslator- Parameters:
path- path in the XML
-
comment
Description copied from interface:TranslatorProcess comment.- Specified by:
commentin interfaceTranslator
-
text
Description copied from interface:TranslatorProcess text.- Specified by:
textin interfaceTranslator
-
isInIgnored
public boolean isInIgnored()Description copied from interface:TranslatorReturns true if the current section should be ignored by parser.- Specified by:
isInIgnoredin interfaceTranslator
-