use of net.heartsome.cat.tmx.converter.AbstractWriter in project translationstudio8 by heartsome.
the class Xlsx2Tmx method doCovnerter.
public void doCovnerter(File2TmxConvertBean file2TmxBean, IProgressMonitor monitor) throws Exception {
Xlsx2TmxHelper tmxConver = new Xlsx2TmxHelper();
attString = Model2String.getCustomArributeXML(file2TmxBean.customeAttr);
AbstractWriter writer = getWriter(file2TmxBean);
if (writer instanceof TmxWriter) {
TmxWriter tmxWriter = (TmxWriter) writer;
tmxWriter.setAttibuteString(attString);
}
// writer.writeHeader(file2TmxBean.srcLangCode);
try {
tmxConver.parseXlsxFileAndWriteTmxBody(file2TmxBean.sourceFilePath, writer, monitor);
} catch (ParserConfigurationException e) {
LOGGER.error("", e);
throw new Exception(Messages.getString("converter.xlsx2tmx.parseExcle.error"));
} catch (SAXException e) {
LOGGER.error("", e);
if ("LANG-CODE-ERORR".equals(e.getMessage())) {
throw new Exception(Messages.getString("converter.common.vaild.langcode.error"));
} else if ("DIFF--SRC-LANG-CODE".equals(e.getMessage())) {
throw new Exception(Messages.getString("converter.common.appendtmx.diffsrcLang.error"));
} else if ("EMPTY-LANG-CODE".equals(e.getMessage())) {
throw new Exception(Messages.getString("converter.common.vaild.langcode.error"));
} else if ("DUPLICATE-LANG-CODE-ERORR".equals(e.getMessage())) {
throw new Exception(Messages.getString("converter.common.vaild.duplicatelangcode.error"));
}
} catch (IOException e) {
LOGGER.error("", e);
throw new Exception(Messages.getString("converter.xlsx2tmx.writeTmx.error"));
} catch (OpenXML4JException e) {
LOGGER.error("", e);
throw new Exception(Messages.getString("converter.xlsx2tmx.parseExcle.error"));
} finally {
writer.writeEnd();
writer.closeOutStream();
monitor.done();
}
}
Aggregations