HI All,
I got this script for the Google Translate function (you can see it at http://translate.google.com/translate_tools):
<div id="google_translate_element"></div><script>
function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: 'en'
}, 'google_translate_element');
}
</script><script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
I added it to an html topic using the Insert Script command using text/js and text/javascript language. I also added the script directly via the Text Editor. I could not get the Google Translate box to display in my topic. If I can make the function display I'll add it to a Master page for all topics.
I sure would appreciate any guidance how to successfully insert this script.
Thank you!
Leigh
inserting google translator script
-
- Propeller Head
- Posts: 17
- Joined: Tue Nov 08, 2011 12:49 pm
Re: inserting google translator script
Try changing this...
<script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit">
to this ...
<script src="http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit">
When I tried it as originally written (which is how Google has it on their site), nothing happened. When I added the http://, I at least got a warning that a script was trying to connect to a source on the Internet, which came up because I ran the test build from my computer instead of a web server. So I think that should work for you.
<script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit">
to this ...
<script src="http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit">
When I tried it as originally written (which is how Google has it on their site), nothing happened. When I added the http://, I at least got a warning that a script was trying to connect to a source on the Internet, which came up because I ran the test build from my computer instead of a web server. So I think that should work for you.
Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
-
- Propeller Head
- Posts: 17
- Joined: Tue Nov 08, 2011 12:49 pm
Re: inserting google translator script
HI Lisa,
Thank you for your reply! I added the http:// to the script but still do not get the Translator. I tried the script with the Language option set as both test/javascript & text/jsscript with the same results, which is /*]]>*/ where the script is positioned in the topic. I also checked my browser settings to be sure it could run the script.
I attached .jpgs (click to expand) of the topic in flare, the Insert Script dialog, & the topic, opened showing the /*]]>*/, in an IE browser.
I really appreciate your help with this--Thank you so much!!
Leigh
Thank you for your reply! I added the http:// to the script but still do not get the Translator. I tried the script with the Language option set as both test/javascript & text/jsscript with the same results, which is /*]]>*/ where the script is positioned in the topic. I also checked my browser settings to be sure it could run the script.
I attached .jpgs (click to expand) of the topic in flare, the Insert Script dialog, & the topic, opened showing the /*]]>*/, in an IE browser.
I really appreciate your help with this--Thank you so much!!
Leigh
You do not have the required permissions to view the files attached to this post.
Re: inserting google translator script
You need to add that sample to the topic in the text editor mode, not by inserting it as a script.
That sample you have is an extract of HTML which already contains some script code and a link inside <script> tags. You would use the insert script option in Flare just for inserting the script code itself (not HTML) or a link, as Flare will enclose it inside <script> tags.
That sample you have is an extract of HTML which already contains some script code and a link inside <script> tags. You would use the insert script option in Flare just for inserting the script code itself (not HTML) or a link, as Flare will enclose it inside <script> tags.
-
- Propeller Head
- Posts: 17
- Joined: Tue Nov 08, 2011 12:49 pm
Re: inserting google translator script
Thanks, Dave.
I tried pasting the below into the text editor:
<div id="google_translate_element"></div><script>
function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: 'en'
}, 'google_translate_element');
}
</script><script src="http://translate.google.com/translate_a ... "></script>
I got nothing (not even /*]]>*/) in my compiled topic. I pasted both above & below the header section but it made no difference.
Any ideas? I appreciate the help!!
All the Best!
Leigh
I tried pasting the below into the text editor:
<div id="google_translate_element"></div><script>
function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: 'en'
}, 'google_translate_element');
}
</script><script src="http://translate.google.com/translate_a ... "></script>
I got nothing (not even /*]]>*/) in my compiled topic. I pasted both above & below the header section but it made no difference.
Any ideas? I appreciate the help!!
All the Best!
Leigh
Re: inserting google translator script
It would need to be placed somewhere after the opening <body> tag because it contains the DIV tags, as well.
Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
Re: inserting google translator script
I was trying this too, and I found that the Google translator script only works on a served page, not a stand-alone help system.
If you are hosting your help on a web server, then you can insert the Google script into a master page, after the <body> tag and before the <MadCap:bodyProxy>, and all works just fine.
The next problem I want to solve is also inserting the code into the generated TOC so that it can be translated as well.
=====
Inserting into toe Toc.htm in the Skin folder works, except that the Google script inserts the very large banner that is mostly inaccessible in the TOC. Would that they would let me turn that off!
BTW, on the Google Translate Help page (http://support.google.com/translate/?hl=en), under "What else should I know about the Element?" it says that the Translate Web Element will work on a hosted web page. I am guilty of not reading the help first!
If you are hosting your help on a web server, then you can insert the Google script into a master page, after the <body> tag and before the <MadCap:bodyProxy>, and all works just fine.
The next problem I want to solve is also inserting the code into the generated TOC so that it can be translated as well.
=====
Inserting into toe Toc.htm in the Skin folder works, except that the Google script inserts the very large banner that is mostly inaccessible in the TOC. Would that they would let me turn that off!
BTW, on the Google Translate Help page (http://support.google.com/translate/?hl=en), under "What else should I know about the Element?" it says that the Translate Web Element will work on a hosted web page. I am guilty of not reading the help first!
Don Johnson
Flare 2020r3, Windows 10 in a Parallels VM on a 16" MacBook Pro [as of March 2021]
Flare 2020r3, Windows 10 in a Parallels VM on a 16" MacBook Pro [as of March 2021]