• [MOD] Google AJAX Translation / Without Page reload 5 0 5 1
Currently:  

Author Topic: [MOD] Google AJAX Translation / Without Page reload  (Read 52111 times)

0 Members and 1 Guest are viewing this topic.

Offline Lucifix

  • Hero Member
  • *****
  • Posts: 710
    • View Profile
    • http://www.slo-foto.net
[MOD] Google AJAX Translation / Without Page reload
« on: January 28, 2009, 09:44:11 PM »
Original MOD writen for Wordpress by Libin Pan and Michael Klein:
http://wordpress.org/extend/plugins/google-ajax-translation/

Description:
This MOD will translate comment to chosen language.

Demo:
http://www.slo-foto.net/galerija_slika-45687.html

Screenshot:


How to do it?
1.
- open templates/[your template folder]/comment_bit.html
- search:
Code: [Select]
{comment_text}
- replace with:
Code: [Select]
<div id="translate_comment_{comment_id}">{comment_text}</div>
2.
- search:
Code: [Select]
{comment_user_icq_button}
Use A (for text) or B (with images)
- A: after add (text):
Code: [Select]
<p>View this Comment in: <a href="javascript:google_translate('en','comment',{comment_id});">English</a> <a href="javascript:google_translate('de','comment',{comment_id});">Deutsch</a> <a href="javascript:google_translate('fr','comment',{comment_id});">French</a></p>
- B: after add (images)
Code: [Select]
<p>View this Comment in: <a href="javascript:google_translate('en','comment',{comment_id});"><img src="{template_url}/images/gb.png" border="0"></a> <a href="javascript:google_translate('de','comment',{comment_id});"><img src="{template_url}/images/de.png" border="0"></a> <a href="javascript:google_translate('fr','comment',{comment_id});"><img src="{template_url}/images/fr.png" border="0"></a></p>- (only if you use B for images) download flags.zip file and upload content to folder:templates/[your template folder]/images/

3.
- open templates/[your template folder]/footer.html

- search:
Code: [Select]
</body>
- before add:
Code: [Select]
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
    google.load('language', '1');
    var original_posts = new Array();
    var original_comments = new Array();
    function google_translate(lang, type, id){
      text_node = document.getElementById('translate_'+type+'_'+id);
      original_text = get_original_text(type, id, text_node);
      to_translate_text = original_text.replace(/<\/?[^>]*>/g, '');
      to_append_text = '';
      if (to_translate_text.length > 500)
        to_append_text = to_translate_text.substr(500);
      to_translate_text = to_translate_text.substr(0, 500);
      google.language.detect(to_translate_text, function(result) {
        if (!result.error && result.language) {
          google.language.translate(to_translate_text, result.language, lang, function(result) {
            if (!result.error)
              text_node.innerHTML = result.translation + to_append_text;
            else
              text_node.innerHTML = original_text;
          });
        }
      });
    }

    function get_original_text(type, id, text_node) {
      switch(type) {
        case 'post':
          original_text = original_posts[id];
          if (original_text == null)
            original_text = original_posts[id] = text_node.innerHTML;
          break;
        case 'comment':
          original_text = original_comments[id];
          if (original_text == null)
            original_text = original_comments[id] = text_node.innerHTML;
          break;
      }
      return original_text;
    }
    function google_translate_callback() {}
    google.setOnLoadCallback(google_translate_callback);
</script>

That's it! Enjoy!  :wink:
« Last Edit: February 01, 2009, 06:32:01 PM by Lucifix »

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: [MOD] Google AJAX Translation / Without Page reload
« Reply #1 on: January 28, 2009, 10:25:42 PM »
... it looks very nice on your site ...
... and thanks for sharing ...
... move to "Mods & Plugins (Releases & Support)" ...
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: [MOD] Google AJAX Translation / Without Page reload
« Reply #2 on: January 31, 2009, 06:58:02 PM »
hey Lucifix ...

... only one word to this modification ... PERFECT ...  :D
... it works now in the best way on my website ...
... thanks again for sharing ...
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline Lucifix

  • Hero Member
  • *****
  • Posts: 710
    • View Profile
    • http://www.slo-foto.net
Re: [MOD] Google AJAX Translation / Without Page reload
« Reply #3 on: January 31, 2009, 07:11:38 PM »
Glad you like it!  :wink:

Offline om6acw

  • Full Member
  • ***
  • Posts: 187
    • View Profile
    • My Animal's World
Re: [MOD] Google AJAX Translation / Without Page reload
« Reply #4 on: January 31, 2009, 10:55:43 PM »
great mod  :!:
congratulation  :!: :!: :!:

Offline om6acw

  • Full Member
  • ***
  • Posts: 187
    • View Profile
    • My Animal's World
Re: [MOD] Google AJAX Translation / Without Page reload
« Reply #5 on: February 01, 2009, 03:50:29 PM »
Somehow I can't see the flags in my comments (http://www.myanimalsworld.com/img_castle_mountain_89.htm), should I put them on my server? or they are located on google site? thanks for reply.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Google AJAX Translation / Without Page reload
« Reply #6 on: February 01, 2009, 06:07:43 PM »
Flags are not part of the mod ;) You'll need add them manually.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline om6acw

  • Full Member
  • ***
  • Posts: 187
    • View Profile
    • My Animal's World
Re: [MOD] Google AJAX Translation / Without Page reload
« Reply #7 on: February 01, 2009, 06:24:58 PM »
Flags are not part of the mod ;) You'll need add them manually.

Ok V@no, i see. Then in this case demo pic should be added without the flags ;) its misleading.

Offline Lucifix

  • Hero Member
  • *****
  • Posts: 710
    • View Profile
    • http://www.slo-foto.net
Re: [MOD] Google AJAX Translation / Without Page reload
« Reply #8 on: February 01, 2009, 06:34:42 PM »
Flags are not part of the mod ;) You'll need add them manually.

Ok V@no, i see. Then in this case demo pic should be added without the flags ;) its misleading.

Okey I added version for images... but next time check some tutorials how replace text with images before you make complain: ;)
http://www.w3schools.com/htmL/html_images.asp

Offline om6acw

  • Full Member
  • ***
  • Posts: 187
    • View Profile
    • My Animal's World
Re: [MOD] Google AJAX Translation / Without Page reload
« Reply #9 on: February 01, 2009, 06:53:39 PM »
Flags are not part of the mod ;) You'll need add them manually.

Ok V@no, i see. Then in this case demo pic should be added without the flags ;) its misleading.

Okey I added version for images... but next time check some tutorials how replace text with images before you make complain: ;)
http://www.w3schools.com/htmL/html_images.asp

no hard feelings my friend, but you are presenting mod with demo page and screen shots, I'm expecting some look after installation on my site, if something what's on your demo information's are not part of the mod you have to mentioned that in installation instructions otherwise you will hear complains.

Offline Lucifix

  • Hero Member
  • *****
  • Posts: 710
    • View Profile
    • http://www.slo-foto.net
Re: [MOD] Google AJAX Translation / Without Page reload
« Reply #10 on: February 01, 2009, 06:58:27 PM »
No hard feelings taken. What bothers me that people ask without trying something by their self.

Offline om6acw

  • Full Member
  • ***
  • Posts: 187
    • View Profile
    • My Animal's World
Re: [MOD] Google AJAX Translation / Without Page reload
« Reply #11 on: February 01, 2009, 07:08:49 PM »
No hard feelings taken. What bothers me that people ask without trying something by their self.

Its not problem for me put images there, but I was expecting them to be there automatically because I saw your demo page and screen shot, That's the reason why I was asking about them.

Offline sanko86

  • Sr. Member
  • ****
  • Posts: 310
    • View Profile
    • Elemegim
Re: [MOD] Google AJAX Translation / Without Page reload
« Reply #12 on: February 03, 2009, 03:24:40 PM »
thank you @Lucifix

good mod

ı mod use the my site: www.elemegim.info
Web site:http://www.anlatiyoruz.com
Hayat zorluklarla doludur.Ama en zoru insanın insana düşmanlığıdır.

Offline mzawdi

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: [MOD] Google AJAX Translation / Without Page reload
« Reply #13 on: February 20, 2009, 04:07:15 AM »
haw add another language

Offline V@nо

  • Addicted member
  • ******
  • Posts: 1.223
    • View Profile
Re: [MOD] Google AJAX Translation / Without Page reload
« Reply #14 on: February 20, 2009, 04:16:00 AM »
Welcome to 4images forum.

Edit code from step 2.
Your first three "must do" before you ask a question:
If I asked you to PM me, I meant PM to my primary account, this account doesn't accept PMs.