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

정보공유

[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 466건 19 페이지
번호 제목 글쓴이 날짜 조회
196 해외 CMS 솔루션 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 02-10 58439
195 Jquery Plugin gallery - Magnific Popup 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 02-07 56567
194 사이트에 연결된 여러개의 도메인을 하나의 도메인으로만 처리되게 방법. 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 01-24 48280
193 [javascript] 이미지 URL 경로만으로 사이즈 구하기 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 01-20 50241
192 KG이니시스와 통신 오류로 결제등록 요청을 완료하지 못했습니다. 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 01-17 45877
191 함수, 클래스 사용가능여부 확인. 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 01-13 39191
190 Methods with the same name as their class will not be constructors in a future version of PHP 오류. 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 01-13 38848
189 table 비동기식 삭제 처리. 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 01-12 35343
188 2차 도메인 뽑아내기. 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 01-05 61322
187 외부에서 자동로그인 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 12-27 42761
186 영카트, 그누보드 모바일화면에서 viewport 처리. 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 12-26 48144
185 윈도우 환경에서 LESS 파일 컴파일 설정 방법 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 12-22 63469
184 모바일에서 헤더부분 상단 고정시킬때 IOS 환경에서 손을때기전에는 활성화가 안되는경우. 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 12-21 50472
183 php 현재 페이지 주소 알아내기 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 12-21 41960
182 [코드이그나이터] 한사이트에 여러도메인 사용하기 위토즈쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 12-14 40159