+ Start a Discussion
Vinay ChVinay Ch 

how to implement google translate in lightning component

Please help me anyone, how to implement below javascript in lightning component, below code help to translate the language change in site page.I implemented same code in VFpage and it's working as expected but same thing i should implement in lightning application

<div id="google_translate_element"></div>
<script type="text/javascript">
        function googleTranslateElementInit() {
             new google.translate.TranslateElement({pageLanguage: 'en', includedLanguages: 'en,sr,zh,th,ko,rosl,hr,ms,uk,et,ar,he,cs,de,fr,el,hu,it,ja,da,pl,zf,nl,no,pt,sk,ru,es,tr,fi,sv,bg,lt,,lv,af,is,ca,sh,id,vi'}, 'google_translate_element');
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

Saket Sharma 37Saket Sharma 37
Hi Vinay,

In lightning there is locker service which dosent allows u to use CDN that means the script u are including is not allowed so for this u need to use vf page to call api's  and then set up the communication between lightning component and vf page. I also faced the same problem when I was integrating google map in lightning. I am sharing u a link u can go through it.


if u get your problem solved then please mark my answer as best answer

Saket Sharma