コード例 #1
0
  /** Saves project file to disk. */
  public static void writeProjectFile(ProjectProperties props) throws IOException {
    File outFile = new File(props.getProjectRoot(), OConsts.FILE_PROJECT);
    String m_root = outFile.getParentFile().getAbsolutePath() + File.separator;

    BufferedWriter out =
        new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile), OConsts.UTF8));
    out.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
    out.write("<omegat>\n");
    out.write("  <project version=\"1.0\">\n");
    out.write(
        "    <source_dir>"
            + computeRelativePath(m_root, props.getSourceRoot(), OConsts.DEFAULT_SOURCE)
            + "</source_dir>\n");
    out.write(
        "    <target_dir>"
            + computeRelativePath(m_root, props.getTargetRoot(), OConsts.DEFAULT_TARGET)
            + "</target_dir>\n");
    out.write(
        "    <tm_dir>"
            + computeRelativePath(m_root, props.getTMRoot(), OConsts.DEFAULT_TM)
            + "</tm_dir>\n");
    out.write(
        "    <glossary_dir>"
            + computeRelativePath(m_root, props.getGlossaryRoot(), OConsts.DEFAULT_GLOSSARY)
            + "</glossary_dir>\n");
    out.write(
        "    <dictionary_dir>"
            + computeRelativePath(m_root, props.getDictRoot(), OConsts.DEFAULT_DICT)
            + "</dictionary_dir>\n");
    out.write("    <source_lang>" + props.getSourceLanguage() + "</source_lang>\n");
    out.write("    <target_lang>" + props.getTargetLanguage() + "</target_lang>\n");
    out.write("    <sentence_seg>" + props.isSentenceSegmentingEnabled() + "</sentence_seg>\n");
    out.write("  </project>\n");
    out.write("</omegat>\n");
    out.close();
  }