위토즈 - 개발자프로그램판매공간

정보공유

[API] [javascript] 구글 자동 번역 API

 

홈페이지에 번역이 필요한경우 자동으로 번역을 해주는 api 입니다.

 

굉장히 심플한 소스입니다.

 

 

<style>
.goog-trans{background:#f0f0f0}
.goog-trans-control{float:left;height:40px}
.goog-trans-control a{display:inline-block;padding:0 10px;height:40px;line-height:40px;background:#383838;color:#fff;text-align:center;text-decoration:none}
.goog-trans-info{float:left;margin:0 0 0 10px;height:40px;line-height:40px;color:#686868}
.goog-trans:after{display:block;visibility:hidden;clear:both;content:''}
</style>

<script>
    function googleSectionalElementInit() {
        new google.translate.SectionalElement({
            sectionalNodeClassName: 'goog-trans-section',
            controlNodeClassName: 'goog-trans-control',
            background: '#78E7FF'
        }, 'google_sectional_element');
    }
</script>
<script src="//translate.google.com/translate_a/element.js?cb=googleSectionalElementInit&ug=section&hl=ko"></script>

<div id="google_sectional_element" style="display:none"></div>
<div class="goog-trans-section">
    <div class="goog-trans">
        <div class="goog-trans-control"></div>
        <div class="goog-trans-info">[번역]을 누르시면 번역이 됩니다.</div>
    </div>
    <div id="google_translate_element_area">The page you are looking at is being generated dynamically by CodeIgniter.</div>
</div>

 

 

 

 

추가적으로 페이지가 로딩되면 바로 번역이 이루어지게 하려면 아래와 같이 javascript 를 추가하시면 됩니다.

 

 

<script type="text/javascript">
    google_initialized = false;

    function google_auto_translate()
    {
        if(google_initialized)
        {
            jQuery('a.goog-te-gadget-link')[0].click();
        }
        else if( jQuery('a.goog-te-gadget-link').length )
        {
            console.log('has button');
            google_initialized = true;
            setTimeout(google_auto_translate, 500);
        }
        else{
            console.log('no button');
            setTimeout(google_auto_translate, 100);
        }
    }

    jQuery(document).ready(function(){
        setTimeout(google_auto_translate, 1000);
    });
</script>

 

 

 

 

 

정보공유
Total 465건 21 페이지
번호 제목 글쓴이 날짜 조회
열람중 [javascript] 구글 자동 번역 API 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 10-20 53774
164 그누보드에 nginx fastcgi_cache 적용하기 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 10-20 64922
163 SMS발송 반드시 발신번호를 등록해야합니다. 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 10-20 58953
162 [asp] 네이버 스마트 에디터 파일업로드 소스 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 10-19 51609
161 KCP 웹표준모듈 적용 코드 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 09-21 43575
160 [javascript] 입력필드(사용자가 키보드를 처서 입력하는)의 입력값이 숫자만 들어가도록 할 때 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 09-20 44083
159 [javascript] 사업자번호체크 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 09-20 43824
158 화면고정하는 방법 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 09-09 38701
157 KISA 암호이용활성화 사이트 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 09-08 61094
156 GCM 이 FCM 으로 통합되었습니다. 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 09-07 55708
155 카카오톡 나에게 보내기 API 키 설정 및 메시지 아이디 설정 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 09-01 59964
154 1차 도메인정보만 추출하기 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 08-31 44614
153 iconv 함수를 사용했는데 결과물이 공백으로 나올경우 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 08-26 42970
152 PHPExcelReader 사용할때 php number_format 사용하지 않고 숫자형 처리 하는 법 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 08-26 65614
151 카카오 API 앱생성 하기 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 08-25 57169