package org.lodder.subtools.sublibrary;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;

import me.champeau.ld.UberLanguageDetector;

import org.apache.commons.io.FileUtils;
import org.lodder.subtools.sublibrary.logging.Logger;

public class DetectLanguage {

  public static String execute(File file) throws Exception {
    String text = readText(file);

    /*
     * text = text.substring(0, 500); Detect.setKey("D6D3A40EDC77276322060DCC2004F50B6CCA351F");
     * Language detectedLanguage = null; try { detectedLanguage = Detect.execute(text); } catch
     * (Exception e) { Logger.instance.error(e.getMessage()); } if (detectedLanguage == null){
     * Logger.instance.log("Cannot detect language pause for 15 seconds before retry!"); try { //
     * Pause for 15 seconds TimeUnit.SECONDS.sleep(15); } catch (InterruptedException e) {
     * Thread.currentThread().interrupt(); // restore // interrupted // status } return
     * execute(file); } return detectedLanguage.toString();
     */

    UberLanguageDetector detector = UberLanguageDetector.getInstance();

    return detector.detectLang(text);

  }

  private static String readText(File file) {
    String text = "";
    try {
      text = FileUtils.readFileToString(file);
    } catch (FileNotFoundException e) {
      Logger.instance.error(Logger.stack2String(e));
    } catch (IOException e) {
      Logger.instance.error(Logger.stack2String(e));
    }

    return text;
  }

}

@@ -207,16 +207,17 @@
 eUtils;%0A
+%0A
 import o
@@ -223,81 +223,171 @@
 org.
-lodder.subtools.sublibrary.logging.Logger;%0A%0Apublic class DetectLanguage %7B
+slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Apublic class DetectLanguage %7B%0A%0A  private static final Logger LOGGER = LoggerFactory.getLogger(DetectLanguage.class);
 %0A%0A  
@@ -1414,134 +1414,115 @@
    L
-ogger.instance.error(Logger.stack2String(e));%0A    %7D catch (IOException e) %7B%0A      Logger.instance.error(Logger.stack2String(e)
+OGGER.error(%22File not found to detect language%22, e);%0A    %7D catch (IOException e) %7B%0A      LOGGER.error(%22%22, e
 );%0A 

Convert DetectLanguage from old logger to new LOGGER slf4j