Page 1 of 2

Google translate

Posted: Tue Aug 21, 2018 10:12 pm
by roze
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?

Re: Google translate

Posted: Wed Aug 22, 2018 11:52 am
by lck
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.

Re: Google translate

Posted: Wed Aug 22, 2018 12:08 pm
by lck
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>

Re: Google translate

Posted: Sun Aug 26, 2018 9:39 am
by roze
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

Re: Google translate

Posted: Sun Aug 26, 2018 10:32 am
by cmb
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.

Re: Google translate

Posted: Sun Aug 26, 2018 11:13 am
by roze
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.

Re: Google translate

Posted: Sun Aug 26, 2018 11:38 am
by lck
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.

Re: Google translate

Posted: Sun Aug 26, 2018 11:39 am
by frase
You have a result -> viewport smaller then 900px:
rob-google.png
The script-place in template is wrong.


Oh, lck was faster ;-)

Re: Google translate

Posted: Sun Aug 26, 2018 12:01 pm
by frase
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.

Re: Google translate

Posted: Sun Aug 26, 2018 5:37 pm
by frase

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?