Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
themes-topic
Language Translation Widget
Avatar
FidoSysop
Clearwater Florida
Member

VIP
sp_UserOfflineSmall Offline
May 27, 2012 - 10:33 am

Figured it would be better to start a new topic for this translation topic. It's a good reference for anyone wanting to do the same.

I was able to cobb the translation widget into spHead.php file. It works fine but has no style and it seemed the only option for placement was either before the php start or the end. Id really like to place it to the right of the user logged in and avatar. Unfortunately I'm not a coder and just know the very basics of php. Any suggestions?

Also since this code is freely available to download from Google, It would make a very useful plugin. I know sometimes my travels wind up on some foreign language site where translation would be useful. I have not tried it yet, but this might also work for a visitor to reply to a message too.wink

  • Doc ~ An old Fidonet SysOp. Just hanging out in cyberspace keeping up with tech.
Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
May 27, 2012 - 12:32 pm

well you would need to add the styling yourself...  and you can put it anywhere in there...  but it may not appear exactly where you want without the styling... 

for next to the avatar/user logged in, try floating it left with class of spLeft...

Avatar
FidoSysop
Clearwater Florida
Member

VIP
sp_UserOfflineSmall Offline
May 27, 2012 - 1:51 pm

Mr Papa said
well you would need to add the styling yourself...  and you can put it anywhere in there...  but it may not appear exactly where you want without the styling... 

for next to the avatar/user logged in, try floating it left with class of spLeft...

Hmmm.. I'm lost in code land.. confused

Anywhere in the header i put it other than before or after the php statement, the whole forum bonks. All that loads is my site header.

Could you give me a little code example please? wink

  • Doc ~ An old Fidonet SysOp. Just hanging out in cyberspace keeping up with tech.
Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
May 27, 2012 - 2:49 pm

you are probably mixing html and php...  please post the code you used, where you want it, including a couple lines before and after the code you inserted...

Avatar
FidoSysop
Clearwater Florida
Member

VIP
sp_UserOfflineSmall Offline
May 27, 2012 - 3:56 pm

I appreciate the coding help. I'm totally lost in that department. Below is the code as it was copied from Google.

    <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>

This is where it's ideal position would be.

translate.jpgImage Enlarger

  • Doc ~ An old Fidonet SysOp. Just hanging out in cyberspace keeping up with tech.
Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
May 27, 2012 - 4:15 pm

yup - mixing php and html... in your spHead.php, just change:

        sp_SectionStart('tagClass=spPlainSection');
            sp_LoggedInOutLabel('tagClass=spLabelSmall spLeft', __sp('Logged in as<br /><b>%USERNAME%</b>'), __sp('Please consider registering<br /><b>guest</b>'), __sp('Welcome back <b>%USERNAME%</b><br />Please log in to post'));
            sp_LogInOutButton('tagClass=spButton spRight', __sp('Log In'), __sp('Log Out'), __sp('Log in and log out'));

to

        sp_SectionStart('tagClass=spPlainSection');
            sp_LoggedInOutLabel('tagClass=spLabelSmall spLeft', 'Logged in as<br /><b>%USERNAME%</b>', 'Please consider registering<br /><b>guest</b>', 'Welcome back <b>%USERNAME%</b><br />Please log in to post');
?>
<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>
<?php
            sp_LogInOutButton('tagClass=spButton spRight', 'Log In', 'Log Out', 'Log in and log out');

Now this will put it pretty much flush up against the stuff on the left... but you can style the 'google_translate_element' div to push it to the right (ie padding-left)...

Avatar
FidoSysop
Clearwater Florida
Member

VIP
sp_UserOfflineSmall Offline
May 28, 2012 - 11:52 am

Ahhh.. That worked. Thanks..smile

So these little doodads stop and start the php execution?  ?> <?php

What would the command be to center that translation code?

  • Doc ~ An old Fidonet SysOp. Just hanging out in cyberspace keeping up with tech.
Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
May 28, 2012 - 1:22 pm

yes, <?php starts a php code block and ?> ends it...  anything outside of that is just written to the file (and thusly should be html)...

you will have an issue trying to center it since you have it 'stacked up' with a bunch of other left or right aligned items... you would need to create sections for the left stuff and right stuff and then add a new section in between with the translate stuff and then use the spCenter class for it...  think that would work, but have not actually tried it...

Avatar
FidoSysop
Clearwater Florida
Member

VIP
sp_UserOfflineSmall Offline
May 29, 2012 - 12:15 pm

Just wondering, would this widgets addition in said header file interfere with my SEO?

  • Doc ~ An old Fidonet SysOp. Just hanging out in cyberspace keeping up with tech.
Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
May 29, 2012 - 2:39 pm

no it shouldnt...

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 619
Members: 17361
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10127
Posts: 79625