Support community for TTG plugins and products.
NOTICE
The Turning Gate's Community has moved to a new home, at https://discourse.theturninggate.net.
This forum is now closed, and exists here as a read-only archive.
You are not logged in.
Pages: 1
Hi.
Perhaps somebody can help me. I want to put the google translator into the nav menu. How can I do this?
This is the code I need to put in:
<div id="google_translate_element"></div><script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'de', includedLanguages: 'de,en,es,fr,sv', autoDisplay: false, multilanguagePage: true}, 'google_translate_element');
}
</script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
I tried it in a tray. That works fine. But I don't want to use a tray.
Regards Kai
Offline
You could use phplugins (the ttg_navigation hook) and float it left or right of the navigation. Graceson has done that with a search form. I'm guessing you could adapt his code, which he's kindly provided here: http://community.theturninggate.net/vie … hp?id=6295
Rod
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site
Offline
Hi.
Thanks for the info. I tried to get it work but I didn't. I am not used to phpplugins. Also just not much to CSS. I got the search-bar working on my page in the navigation bar as Graceson has it on his page. But I don't get the google translation code in that example that it will work. I have to wait until somebody with knowledge wants to put the google translator also in the nav bar. :-)
Regards Kai
Offline
If you can tell us what it should look like and how it wasn't working, we might be able to figure it out.
My guess is that there is a syntax problem (some of that code uses single quotes, which would break things)
You said it worked in a tray. It would be very useful if you could create a page with it in the tray and post a link to that page.
Rod
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site
Offline
Thanks. So here the link:
http://meridian.dynalias.org:31005/fotogallerie/
I just put the google translator code, as posted above in the first post, into the "home"-page under "tray 1".
That would be a nice and easy way to translate all the pages. Because it also changes the language within all the galleries-windows and sets. Nobody has to think about different subdomains and additional galleries for every language.
Regards Kai
PS: Perhaps you can also put it in as an on/off-switch within the settings of backlight. So everybody can use it or not as the favicon for example.
Last edited by lulu99 (2016-06-28 22:55:39)
Offline
I've been trying to get that Google translate thing to show up in the navigation bar. I can get plain text to show up where I want it in the bar, but the Google thing just doesn't want to show up. There's probably some css that will make it appear, but I've not found it and don't have time to go down that rabbit hole.
I was, however, able to get it to show up in other parts of the page. For example, at the top of the page:
http://backlight-rb-test.barbeephoto.co … -translate
If you want to try this, let me know and I'll post the code.
Rod
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site
Offline
Hi Rod.
Thank you for your help! It is strange. Perhaps you can give it one more try with this new code here. This time it looks a bit different and the box is another one. Perhaps this box works in the nav-bar because it has a different layout from the first one.
<div id="google_translate_element"></div><script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'de', includedLanguages: 'de,en,es,fr,sv', layout: google.translate.TranslateElement.InlineLayout.SIMPLE, autoDisplay: false, multilanguagePage: true}, 'google_translate_element');
}
</script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
Regards Kai
Offline
you can try it too.
Here's what I'm trying right now in phplugins to get the thing in the nav bar:
function ttg_navigation( $style, $path ) {
echo '
<div class="headfloat-nav">
<div id="google_translate_element"></div><script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: \'de\', includedLanguages: \'de,en,es,fr,sv\', autoDisplay: false, multilanguagePage: true}, \'google_translate_element\');
}
</script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
</div> <!-- Google Translate -->
'; return true;
} // END
And this is how I'm styling it in custom css:
/*Styling for google translate in navigation
===========================================*/
.headfloat-nav {
float: right;
z-index: 1;
position: relative;
margin: 0 20px 0 0;
}
.headfloat-nav p {
margin: .5em 0 0 0;
}
but as you can see here, nothing is happening on the front end of the page, though I see the code in the page source:
http://backlight-rb-test.barbeephoto.co … nslate-nav
if you want to try your new code, be sure to escape all the single quotes by preceding them with a backslash \
Rod
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site
Offline
I used your code. I kept the tray on the right side. Now have a look. It is in the tray?!?!?!? Strange... That seems to be the reason why you don't see it on your page. There is no tray.
When I change the tray to the left side the translator is moving with it to the left side.
Last edited by lulu99 (2016-06-29 06:54:36)
Offline
I tried placing the translator code in a tray and it worked fine. Just haven't been able to place it in the navigation area. It shows up in the page's source code, it's just not visible on the page itself when placed in navigation.
the code I posted is meant to go into a phplugins file. If you're going to put the translate tool in the tray, just use the code you already have.
Rod
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site
Offline
I used the code from you in your post. Including phpplugin. But with that code it also shows up in the tray. Isn't that strange?
If you look on my page you see it in the tray. But with the code you gave me to put it in the custom.css and the phpplugin. No code in any tray presently.
Last edited by lulu99 (2016-06-29 07:30:41)
Offline
, it's just not visible on the page itself when placed in navigation.
Just switch on the tray for that page and you will see that you can see it in the tray. That was what I meant. Sorry.
Last edited by lulu99 (2016-06-29 07:33:25)
Offline
well, I don't think that should be happening. But I see what you mean, it appeared on my test page in the tray when I activated the tray. It's showing up there because the navigation is set to appear in the tray on mobile devices. If you disable tray navigation, the translator will disappear from the tray but will then appear in the navigation bar.
But you'll still have the tray showing.
But the trade-off is having no navigation in the tray for mobile devices, so not a good solution.
Must be something to do with the fact that the code is a script. But I don't know enough about the page construction to offer any solution.
For now, if you want to use this, I suggest placing it in the tray deliberately or placing it elsewhere on the page (other than the navigation hook) using phplugins.
Maybe Matt will have a suggestion/solution for putting the script in the navigation. Might be the solution is to separate the script from the html, placing the script in the phplugins ttg_scripts hook.
Maybe I'll try that next.
Rod
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site
Offline
Nevertheless many thanks that you tried it!!! Perhaps somebody will find a solution in the future. Would be a nice feature to have it in the nav-bar. Best place to put it there. :-) But good to see that we don't want to give up. :-)
Regards Kai
Last edited by lulu99 (2016-06-29 07:59:09)
Offline
I just tried separating the html from the script. Same results. The code is showing up in the page source, just not on the page itself.
Might be that the script is conflicting with what's being done behind the scenes in Backlight to construct the navigation. But I'm not that good with javascript....
here's my test page in case someone else out there has any suggestions.
http://backlight-rb-test.barbeephoto.co … nslate-nav
Rod
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site
Offline
Offline
Rainer,
was that intended for this forum? It doesn't seem to have anything to do with the topic.
Rod
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site
Offline
Pages: 1