improvement in dynamic size of gui
improvement in dynamic size of gui
Adoption google translator API but correcting 3 points:

        //corrected method by jrichardsz
        //problem of google api: if you translate a text hello, the output is:
        //hola,hola,,,,en,,hola,5,1,0,1000,0,1,0,hola,5,hola,1000,1,0,de Hola,0,1,0,0,4,hola,,,es,en,3
        //then as the result is the text before the first "," they make a split[,] and return split[0]
        //All is ok but if you translat a text whit "," the split[0] the remaining text will be lost
        @Override
        public void parse() {
                appendURL();
                String result = WebUtils.source(url.toString());
                //correction:return the original output and develop a algotimo to extract only the word translated
                //result = result.replace("[", "").replace("]", "").replace("\"","");
                Text output = textTranslate.getOutput();
                output.setText(result);
        }

        //corrected method by jrichardsz
        //problem of google api: the URL is not dynamic : http://translate.google.com.br/translate_a/t?
        // is only for "br"
        @Override
        public void appendURL() {
                Text input = textTranslate.getInput();
                Text output = textTranslate.getOutput();
                //correcction of google api: dynamic URL and not just br : http://translate.google.com.br/translate_a/t?
                url = new StringBuilder(URLCONSTANTS.GOOGLE_TRANSLATE_TEXT.replaceAll(".br", "."+getLocale()));
                url.append("client=t&text=" + input.getText().replace(" ", "%20"));
                url.append("&hl=" + input.getLanguage());
                url.append("&sl=" + input.getLanguage());
                url.append("&tl=" + output.getLanguage());
                url.append("&multires=1&prev=btn&ssel=0&tsel=0&sc=1");
        }

    // method that enables the use of proxies in the Google Translate API
    In metodo source of WebUtil class, change:

//  urlConn = url.openConnection(); by
    urlConn = getURLConnection(url);

//  using this:

    private static URLConnection getURLConnection(URL url){

        try{
            String enable = TranslatorParameters.getProperty("enable.proxy");

        if(enable!=null && enable.equalsIgnoreCase("n")){
             return url.openConnection();
        }else {
            String proxy = TranslatorParameters.getProperty("http.proxy");
            String port = TranslatorParameters.getProperty("http.proxy.port");
            Proxy prox = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxy, Integer.parseInt(port)));
            return url.openConnection(prox);
        }
        }catch(IOException e){
            return null;
        }catch(Exception e){
            return null;
        }
    }