예제 #1
0
 public static void fixTag(
     SourceTextEntry ste, Tag tag, TagError error, StringBuilder translation, String source) {
   List<Tag> tags;
   switch (error) {
     case DUPLICATE:
     case ORDER:
     case MALFORMED:
       tags = TagUtil.buildTagList(source, ste.getProtectedParts());
       fixMalformed(tags, translation, tag);
       break;
     case MISSING:
       tags = TagUtil.buildTagList(source, ste.getProtectedParts());
       fixMissing(tags, translation, tag);
       break;
     case EXTRANEOUS:
       fixExtraneous(translation, tag);
       break;
     case ORPHANED:
       // This is fixed by fixing MISSING.
       break;
     case WHITESPACE:
       fixWhitespace(translation, source);
       break;
     default:
       break;
   }
 }
예제 #2
0
  /**
   * Identify all the placeholders in the source text and automatically inserts them into the target
   * text.
   */
  public void editTagPainterMenuItemActionPerformed() {
    SourceTextEntry ste = Core.getEditor().getCurrentEntry();

    // insert tags
    String tr = Core.getEditor().getCurrentTranslation();
    for (ProtectedPart pp : ste.getProtectedParts()) {
      if (!tr.contains(pp.getTextInSourceSegment())) {
        Core.getEditor().insertText(pp.getTextInSourceSegment());
      }
    }
  }
예제 #3
0
  public void editExportSelectionMenuItemActionPerformed() {
    if (!Core.getProject().isProjectLoaded()) return;

    String selection = Core.getEditor().getSelectedText();
    if (selection == null) {
      SourceTextEntry ste = Core.getEditor().getCurrentEntry();
      TMXEntry te = Core.getProject().getTranslationInfo(ste);
      if (te.isTranslated()) {
        selection = te.translation;
      } else {
        selection = ste.getSrcText();
      }
    }

    FileUtil.writeScriptFile(selection, OConsts.SELECTION_EXPORT);
  }
예제 #4
0
  public void editTagNextMissedMenuItemActionPerformed() {
    String trans = Core.getEditor().getCurrentTranslation();
    if (trans == null) {
      return;
    }

    SourceTextEntry ste = Core.getEditor().getCurrentEntry();

    // insert next tag
    String tr = Core.getEditor().getCurrentTranslation();
    for (ProtectedPart pp : ste.getProtectedParts()) {
      if (!tr.contains(pp.getTextInSourceSegment())) {
        Core.getEditor().insertText(pp.getTextInSourceSegment());
        break;
      }
    }
  }