Google translate

About the template and stylesheet - and changing the menu
roze
Posts: 270
Joined: Tue Jun 03, 2008 7:13 am
Location: NL
Contact:

Google translate

Post by roze » Tue Aug 21, 2018 10:12 pm

I want to use "Google Translate" in my website www.beremooiehymers.nl

It says: paste the script in evere page you want use "Translate"
<div id="google_translate_element"></div><script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'nl', includedLanguages: 'de,en'}, 'google_translate_element');
}
</script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
I've paste this in the HTML code from the home page => nothing happens.

Is there a way to use this script so it appears on top on every page?
Rob Zeijen,

Valkenswaard (NL)

lck
Posts: 2963
Joined: Wed Mar 23, 2011 11:43 am
Contact:

Re: Google translate

Post by lck » Wed Aug 22, 2018 11:52 am

First you have to teach the tinymce that it does not delete script tags, see here.
Very important, there must be no space between the span[*],script[*]! So it should look like this:

Code: Select all

extended_valid_elements: 'span[*],script[*]'
In this Thread is also an option for the userfuncs.php described, how to create a plugin call and thus the script can be easily integrated into each page.
„Bevor du den Pfeil der Wahrheit abschießt, tauche die Spitze in Honig!“   👉 Ludwig's XH-Templates for MultiPage & OnePage

lck
Posts: 2963
Joined: Wed Mar 23, 2011 11:43 am
Contact:

Re: Google translate

Post by lck » Wed Aug 22, 2018 12:08 pm

roze wrote:
Tue Aug 21, 2018 10:12 pm
Is there a way to use this script so it appears on top on every page?
You could save the script in a hidden page e.g. "Google Translate" and then call the page in the template.htm as a newsbox.

Code: Select all

<div class="googleTranslate"><?php echo newsbox('Google Translate');?></div>
or only on a side:

Code: Select all

<div>{{{newsbox('Google Translate');}}}</div>
„Bevor du den Pfeil der Wahrheit abschießt, tauche die Spitze in Honig!“   👉 Ludwig's XH-Templates for MultiPage & OnePage

roze
Posts: 270
Joined: Tue Jun 03, 2008 7:13 am
Location: NL
Contact:

Re: Google translate

Post by roze » Sun Aug 26, 2018 9:39 am

Ick,

I've made a hidden page <Google Translate> with the script

I placed te script in the template:

Code: Select all

<div class="googleTranslate"><?php echo newsbox('Google Translate');?></div>
But now I see the text of the script on top of every page like this:

http://www.beremooiehymers.nl/?start
Rob Zeijen,

Valkenswaard (NL)

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Google translate

Post by cmb » Sun Aug 26, 2018 10:32 am

roze wrote:
Sun Aug 26, 2018 9:39 am
But now I see the text of the script on top of every page like this:
It seems that you have entered the script in the WYSIWYG mode of the editor; you have to use the HTML mode instead.

However, why don't you put the script directly into the template? I don't see the need for having a newsbox for this purpose.
Christoph M. Becker – Plugins for CMSimple_XH

roze
Posts: 270
Joined: Tue Jun 03, 2008 7:13 am
Location: NL
Contact:

Re: Google translate

Post by roze » Sun Aug 26, 2018 11:13 am

indeed: I placed it in the WYSIWYG ;)

But I've placed it now in the template like this:

Code: Select all

<!-- navigation END -->

     <!-- expandable navigation START -->
     <div id="expand-menu">
          <div class="expand-box">
               <div class="expand-searchbox">
                    <?php echo searchbox();?>
               </div>
               
               
<div id="google_translate_element"></div><script type="text/javascript">
function googleTranslateElementInit() {
  new google.translate.TranslateElement({pageLanguage: 'nl', includedLanguages: 'de,en', layout: google.translate.TranslateElement.InlineLayout.HORIZONTAL}, 'google_translate_element');
}
</script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>



               <div class="menu-button">
                    <img src="<?php echo $pth['folder']['templateimages'];?>menu-on.png">     
               </div>
          </div>
          <div class="expand-toc">
               <?php echo toc();?>
          </div>
     </div>
     <!-- expandable navigation END -->
But this gives me no result.
Rob Zeijen,

Valkenswaard (NL)

lck
Posts: 2963
Joined: Wed Mar 23, 2011 11:43 am
Contact:

Re: Google translate

Post by lck » Sun Aug 26, 2018 11:38 am

cmb wrote:
Sun Aug 26, 2018 10:32 am
However, why don't you put the script directly into the template? I don't see the need for having a newsbox for this purpose.
In this case, probably the best solution.
roze wrote:
Sun Aug 26, 2018 11:13 am
But I've placed it now in the template like this:
Yet it is present, but hidden from a viewport of 900 px. Resize your browser window. You should find another place for this.
„Bevor du den Pfeil der Wahrheit abschießt, tauche die Spitze in Honig!“   👉 Ludwig's XH-Templates for MultiPage & OnePage

frase
Posts: 5085
Joined: Thu Apr 21, 2016 6:32 am
Location: Saxony
Contact:

Re: Google translate

Post by frase » Sun Aug 26, 2018 11:39 am

You have a result -> viewport smaller then 900px:
rob-google.png
The script-place in template is wrong.


Oh, lck was faster ;-)
You do not have the required permissions to view the files attached to this post.

frase
Posts: 5085
Joined: Thu Apr 21, 2016 6:32 am
Location: Saxony
Contact:

Re: Google translate

Post by frase » Sun Aug 26, 2018 12:01 pm

A better way to translate your website.
For users very simple & comfortable.
Place a simple Link, e.g.:

Code: Select all

<a href="https://translate.google.com/translate?u=http://www.beremooiehymers.nl/?Start">Google translate</a>
For "?Start" you must write a php-code for the actually page.

frase
Posts: 5085
Joined: Thu Apr 21, 2016 6:32 am
Location: Saxony
Contact:

Re: Google translate

Post by frase » Sun Aug 26, 2018 5:37 pm

Code: Select all

<a href="https://translate.google.com/translate?u=<?=$sn.'?'.$su;?>" target="_blank">Google translate</a>
@Christoph
Ist das eine korrekte Möglichkeit, die vollständige Seiten-Adresse an Google zu übergeben?
Oder geht das smarter?

Post Reply