RE: [Htmlparser-developer] Language Support
Brought to you by:
derrickoswald
From: Claude D. <CD...@ar...> - 2002-08-06 16:41:59
|
I've been reading further on the use of InputSource in XML and recall your interest in using a similar mechanism. In practice it seems easy enough to do this and I've provided some same code to illustrate. The InputSource provides either a Reader, InputStream of System ID (usually a local file name) and they can be checked for existence, in that order. =20 I raise this issue (in this context) because one of the reasons the XML community adopted the InputSource was because it could contain additional information about he character set encoding (which is not used here but could be). This becomes much more important if you start considering internationalization. =20 Here's some sample code that is compilable (but untested - though it should work): import java.io.*; import org.xml.sax.*; import com.kizna.html.util.HTMLParserException; =20 public class InputSourceReader extends BufferedReader { public InputSourceReader(InputSource source) throws HTMLParserException { super(getReaderFromInputSource(source)); } =20 protected static Reader getReaderFromInputSource(InputSource source) throws HTMLParserException { Reader reader =3D source.getCharacterStream(); if (reader !=3D null) { return reader; } =20 InputStream input =3D source.getByteStream(); if (input !=3D null) { return new InputStreamReader(input); } =20 String systemId =3D source.getSystemId(); if (systemId !=3D null) { try { return new FileReader(systemId); } catch (FileNotFoundException e) { throw new HTMLParserException("Invalid InputSource", e); } } throw new HTMLParserException("Invalid InputSource"); } } -----Original Message----- From: Somik Raha [mailto:so...@ya...]=20 Sent: Monday, August 05, 2002 7:07 PM To: htm...@li... Subject: [Htmlparser-developer] Language Support Hi Folks, Amit Rana is a new developer on HTMLParser. He has considerable experience in internationalization - and he is currently working to enable language support and switching. Two languages high on my list are - French and Finnish, considering we've had French and Finnish developers on this project. We also want to do Japanese support. The architecture that Amit is trying is nice - it will simply require publishing of a standard English properties file - and for any language support, a corresponding translated properties file will be loaded up. Amit --> you can probably give a more detailed explanation here. =20 Regards, Somik |