Support Forum

Language Translation Widget

EK Edward Koon
Edward Koon
Member

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

10 Answers

New Answer

MP Mr Papa
Mr Papa
Member

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…

EK Edward Koon
Edward Koon
Member

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

MP Mr Papa
Mr Papa
Member

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…

EK Edward Koon
Edward Koon
Member

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.jpg
MP Mr Papa
Mr Papa
Member

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

EK Edward Koon
Edward Koon
Member

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?

MP Mr Papa
Mr Papa
Member

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…

EK Edward Koon
Edward Koon
Member

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

EK Edward Koon
Edward Koon
Member

I think the time it took to load was causing problems adding content to Facebook & Google +1.

Every time i pasted a forum link into either of those sites they never came up with image thumbnails. Removing the widget seemed to cure the problem.

I might try and use a table on the forum page to add the widget and some add this code. Trying to stay away from using a sidebar on the forum page. Let the forum have all the resources.