Package com.liferay.portlet.translator.model

Examples of com.liferay.portlet.translator.model.Translation


    _translationId = translationId;
    _fromText = fromText;
  }

  public Object convert(String id) throws ConverterException {
    Translation translation = new Translation(_translationId, _fromText);

    try {
      StringBuffer url = new StringBuffer();
      url.append("http://babelfish.altavista.com/babelfish/tr?doit=done");
      url.append("&urltext=").append(Http.encodeURL(_fromText));
      url.append("&lp=").append(_translationId);

      String text = Http.URLtoString(new URL(url.toString()));

      int begin = text.indexOf("<div style=padding:10px;>") + 25;
      int end = text.indexOf("</div>", begin);

      String toText = text.substring(begin, end).trim();
      toText = StringUtil.replace(toText, "\n", " ");

      translation.setToText(toText);
    }
    catch (Exception e) {
      throw new ConverterException(e);
    }
View Full Code Here


    try {
      String translationId = ParamUtil.getString(req, "id");
      String fromText = ParamUtil.getString(req, "text");

      if (Validator.isNotNull(fromText)) {
        Translation translation =
          TranslatorUtil.getTranslation(translationId, fromText);

        req.setAttribute(WebKeys.TRANSLATOR_TRANSLATION, translation);
      }
    }
View Full Code Here

    try {
      WebCacheable wc =
        new TranslationConverter(translationId, fromText);

      Translation translation = (Translation)wc.convert("");

      toText = translation.getToText();

      if ((toText != null) &&  (toText.indexOf("Babel") != -1)) {
        Logger.info(this, "Please manually check for errors.");
      }
    }
View Full Code Here

TOP

Related Classes of com.liferay.portlet.translator.model.Translation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.