2

I m looking for a way to reuse the 2 scripts provided by google translate to implement the auto translation in an angular application without injecting them in the dom. Like a way to convert them to internal function in my component.

I m taling about the 2 scripts + the hidden div element :

<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit" defer=""></script>


<script type="text/javascript">
                     function googleTranslateElementInit() {
                     new google.translate.TranslateElement(
                     {
                       pageLanguage: 'ko',
                       includedLanguages: 'en',
                       layout: google.translate.TranslateElement.FloatPosition.TOP_LEFT,
                       autoDisplay: false
                     },
                     'google_translate_element');}</script>



<div class="hidden" id="google_translate_element"></div>

1 Answer 1

1

Instead

//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit

You should

https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit

You missed https: thats why its not working

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.