private void addWikiTranslation(String key, String message, Locale locale) throws XWikiException {
    XWikiDocument document =
        this.oldcore
            .getMockXWiki()
            .getDocument(this.defaultWikiTranslationReference, this.oldcore.getXWikiContext());

    if (!locale.equals(Locale.ROOT)) {
      XWikiDocument translatedDocument =
          document.getTranslatedDocument(locale, this.oldcore.getXWikiContext());
      if (translatedDocument == document) {
        translatedDocument = new XWikiDocument(document.getDocumentReference(), locale);
        translatedDocument.setDefaultLocale(document.getDefaultLocale());
      }
      document = translatedDocument;
    }

    document.setSyntax(Syntax.PLAIN_1_0);

    StringBuilder builder = new StringBuilder(document.getContent());

    builder.append('\n');
    builder.append(key);
    builder.append('=');
    builder.append(message);

    document.setContent(builder.toString());

    this.oldcore.getMockXWiki().saveDocument(document, "", this.oldcore.getXWikiContext());

    setBundles(document.getFullName());
  }
  @Override
  public void setWikiDocumentParameters(String name, FilterEventParameters documentParameters)
      throws FilterException {
    DocumentReference reference =
        new DocumentReference(name, new SpaceReference(this.currentReference));

    XWikiContext xcontext = this.xcontextProvider.get();

    XWikiDocument defaultDocument;
    try {
      defaultDocument = xcontext.getWiki().getDocument(reference, xcontext);
    } catch (XWikiException e) {
      throw new FilterException("Failed to get document [" + reference + "]", e);
    }

    documentParameters.put(WikiDocumentFilter.PARAMETER_LOCALE, defaultDocument.getDefaultLocale());
  }