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

정보공유

[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 48건 3 페이지
번호 제목 글쓴이 날짜 조회
18 KCP 모바일결제 오류 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 08-23 36406
17 KCP 결제 승인취소할경우 8012 에러코드 원인. 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 07-06 38109
16 새로 변경된 네이버 api 키 등록방법 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 04-11 32769
15 다음 지도 사용법, 적용법, 소스코드 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 05-13 47730
14 구글 웹사이트 번역기를 내 사이트에 달기. 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 09-03 36778
13 트위터 consumer key 받기. 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 05-09 33129
12 페이스북 글 가져오기 쉬운방법. 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 05-09 45331
11 [고도몰 튜닝 팁 Tip] LG U플러스 PG 결제모듈 연동시 IE환경에서의 희한한 상황. 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 02-26 34429
10 짧은주소. 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 01-22 45472
9 결제 대행 PG사 모음. 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 01-15 47310
8 페이스북 글 가져오기 (개인) 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 01-05 43118
7 페이스북 글 가져오기 (페이지) 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 01-05 45304
6 네이버 아이디 로그인. 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 12-13 41953
5 새주소 php스쿨 오픈 api 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 12-09 43453
4 무료 채팅 솔루션 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 11-02 42661