• Welcome to Simple Machines Community Forum. Please login or sign up.
December 09, 2021, 02:05:09 AM

News:

Join the Facebook Fan Page.


Google Translator Flags Mod

Started by roco, March 04, 2010, 10:50:16 PM

Previous topic - Next topic

roco

Link to Mod

Version: 1.0 Date: January 10, 2o1o
Compatibility: 1.1.x and 2.0



Google Translate Flags Mod - v1.0
by Roco - priv Polish SMF-Help! Board



Link to Mod | Support Topic | Demo and My Own Suport




Google Translate Flags Mod for SMF will:

Integrate Google Translate widget, into SMF Board
However, the modification does not add any scripts.

This Mod change files:

SMF 1.1.11 - Themes/default/
  • Display.template.php

SMF 2.0 - Themes/default/ (the Curve Theme)
  • Display.template.php

The mod will update only the default templates, for another please read install[1 or 2].xml
- and is easy for integration with different styles as well.

= = = = = = = = = = = = = = =


Google Translate Flags
Google Translate Flags Mod Overview


This is a modification, not for you but for your guests :)

With this modification, your guests will be able to better understand the Content for your forum.
The modification adds a mini-pictures, these are the flags of Countries, when you click on the desired flag,
will translate the Topic, the chosen language. Interpreter, is Google Tranlator.
The Google gadget is here: http://translate.google.com/translate_tools?hl=en


The modification includes a folder with over 240 flags of countries!
Very simply, you can add a new flag, just look at the file install[1 or 2]. xml

I turned 12 languages, but may be any number, and it just depends on your needs.

+ This is a simple very simple, but needed modification, and no problems with installation.
+ It looks much better than the Google gadget ugly, look at sreenshot.
+ I did not include any slowing down the script, it's just image links ... ;)
+ Your guests will have a chance to understand better the content of the Topics
+ The modification does not need any language files.

And I hope that the modification appears to you to help, and your guests will be happier,
- being able to better understand the content of yours Topics.


Phrases used in links:

- hl=en --> is the language of the guest when the visitor clicks on the translation, was given in English,
which is the universal language.. here Please do not change anything!

- sl= --> a language that is the source of your page and it is dependent on the set default language forum - in PA,
here Please do not change anything!

- tl= --> sign language to be translated Topic, and if we add language translation,
it is here to enter code language (the code of country) and the same for the link to "picture".png
For example, tl=de (This is code of German country), in an image link in src must add de.png

Note! - that these flags are named using the ISO3166-1 alpha-2 country codes where appropriate.
A list of codes can be found at http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2

Some time Google Translator however sees it differently for example, Japan has approved the code, "jp",
- this time on google translator is the code "ja". ect ect

Therefore, before making changes, you must compare what the WiKi and the google translator.

Have fun width the mod :)

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

Changelog
1.0 - 10th January 2010
-  Initial Release


Best Regards :)
Roco

ylon


roco

March 09, 2010, 11:23:22 AM #2 Last Edit: March 10, 2010, 03:56:26 PM by roco
Hi :)

When this Mod realy help You, please Welcome :)

Friends,

This mod is compatibile with SMF 2.0 RC 3 to, please look:



and on Package Manager:




On my forum, people ask whether it is possible to translate Mod other places?
Pondered this and came to the conclusion that it is possible 2 places
- MessageIndex.template and BoardIndex.template.

The main goal of this Modification is the translation of topics.
But I understand the need for the translation of the names (category and topics) on the Board Index and the Message Index.
If there is interest, it will demonstrate how to do this.

In any event, I did not want to mod was placed in index.template, because you could not guarantee your privacy!

Modification by clicking on the desired flag translators in that language, but the translator is on another page,
and what you see in translatorze is generated page, already translated into the chosen language.
This is not your forum page! Modifications itself only adds graphic links to Translator.

If there is interest in additional sites, of course, I'll show you how to do this, the problem is that every vote is another opinion - it comes to a place
I'll show you wonder why the proposals:

BoardIndex.template :




and MessageIndex.template :



I wrote about this here: Topic <-- click
Please use the translator, because the page is in Polish.

Best Regards :)
roco

.


kosaic

March 09, 2010, 03:53:35 PM #3 Last Edit: March 09, 2010, 04:47:22 PM by kosaic
Hi,

Great Mod, but it does not work on my site. The mod installs no problem, the flags show up fine, but the Links just go back to the page you are on. They do not go to Google Translate at all.

It can be seen here: fundyschutzhund.ca/forums/

Take a look at a post, and you will see what I mean.....

Thoughts ?

I'm wondering if this has something to do with the "Pretty URL's Mod"  ?? If so, How do I fix it is the question.

EDIT: I just turned off URL re-writing in Pretty URL's , and the Google Translator Mod works ... ! Now I have to figure out how to fix this issue so I can leave Pretty URL's turned on.

HEre is the Pretty URL's .htaccess detail ... Anyone have any thoughts ?
# Rules for: boards
RewriteRule ^([-_!~*'()$a-zA-Z0-9]+)/?$ ./index.php?pretty;board=$1.0 [L,QSA]
RewriteRule ^([-_!~*'()$a-zA-Z0-9]+)/([0-9]*)/?$ ./index.php?pretty;board=$1.$2 [L,QSA]

# Rules for: topics
RewriteRule ^([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/?$ ./index.php?pretty;board=$1;topic=$2.0 [L,QSA]
RewriteRule ^([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/([0-9]*|msg[0-9]*|new)/?$ ./index.php?pretty;board=$1;topic=$2.$3 [L,QSA]

roco

Hi, :)

Of course, the problem with links, because Pretty URL's cuts needed characters in links.. sorry for that..

At this point I can not install on any of the test servers Pretty URL's, because there is the Apache software dynamic link,
mod_rewrite works, also htaccess works, but does not work Pretty Url's,
unfortunately, I also move from one computer to another, and have not yet installed the server Apache.

I do not know how to do this test, and the head I will not do, I have a little knowledge of mod_rewrite, sorry ..
I think that as soon as you can ask a question on the bottom bracket Pretty URL's Mod, here on the forum. Dannii or vbgamer45 are certainly required knowledge.
I would like you to help a lot, but for the moment, without tools and opportunities - do not give advice, so it may ask this question here:
http://www.simplemachines.org/community/index.php?topic=146969.0 ?


Returning to mod ..

This is your topic: http://fundyschutzhund.ca/forums/bh/bh-general-information/msg4/#msg4

Let us say we want to translate it into German, it should look like this:
http://translate.google.com/translate?hl=en&sl=en&tl=de&u=http://fundyschutzhund.ca/forums/bh/bh-general-information/msg4/#msg4

The modification of links with pictures look like this (ins mod):


<a href="http://translate.google.com/translate?hl=en&amp;sl=', $txt['lang_dictionary'], '&amp;tl=de&amp;u=', $scripturl, '?topic=', $context['current_topic'], '.0.html" title="Ins Deutsche übersetzen [DE]" target="_blank"><img src="', $settings['default_theme_url'], '/images/gtflags/de.png" alt="[DE]" style="border:none;" /></a>


See? worked so it must be: topic = ', $ context [' current_topic '],' - because we want to translate this: - current topic!
And only if that makes sense ..

So that worked with the Pretty URL's need to fit such a structure of link:


http://translate.google.com/translate?hl=en&amp;sl=', $txt['lang_dictionary'], '&amp;tl=de&amp;u=', $scripturl, '?topic=', $context['current_topic'], '.0.html


or may be short:


http://translate.google.com/translate?hl=en&amp;sl=', $txt['lang_dictionary'], '&amp;tl=de&amp;u=', $scripturl, '?topic=', $context['current_topic'], '



The source of the page shows that half of the link is cut, and is as follows:

http://fundyschutzhund.ca/forums/bh/bh-general-information/

instead be as follows:

http://translate.google.com/translate?hl=en&sl=en&tl=de&u=http://fundyschutzhund.ca/forums/bh/bh-general-information

In this way, does this Mod, it is certainly possible to adapt both the modification.
I do not know how to solve on the fly, but I am convinced that a solution exists.
I am sorry that I could not help, but I hope that my information will be useful.

Yours :)
roco

kosaic

Thanks roco !

I understand the problem of the link getting cut in half (losing the translation part) , but I have no clue as to how to fix it.

I have played with it today, but I think that the Pretty URL guys may have to take a peek, and make suggestions ? Or someone VERY familiar with URL re-writing.

Thanks for looking into it !

roco

hehe why Thanks when I not help You? ;)

I have write a post here: http://www.simplemachines.org/community/index.php?topic=146969.msg2531361#msg2531361

hmm my english is verry bad, But I think people understand that?

I am a webmaster, I know the code, I write the same time, styles and modifications, but do not yet know many things
A man learns his life to the end state that still knows little hehe
I will review the modification (Pretty URLs) could invent something, but unfortunately I have no where to test, (in this moment!).
May be others can come up with something?
I think that Google Translator Mod is very much needed and at the same time simple modification ..

Regards :)
roco

Sudhakar Arjunan

Excellent Mod Roco.

Good to big forum. Where we could have more language audience .

Thank you for the good work.
Working on New Mods & Themes for SMF... Will update soon... My Blog page
My Smf forum : Discuss ITAcumens :: My SMF Forum

roco

Please Welcome :)

And now Your Forum is more frendly for Your users and is more usability to.. ;)
For me self this is verry important Mod ..for better community!

You can very easily set more or less language, or choose the ones that are most needed.
Mod contains a folder of over 240 graphics flags.

BTW I know Your Big Forum :)
And I think that RSS feed, (The small grafics on Board Index) for this beautiful Theme,
more would fit with this little graphic:

This is example:



Best Regards :)
roco

anakmacan

March 12, 2010, 12:32:53 PM #9 Last Edit: March 12, 2010, 12:42:53 PM by anakmacan
EXACTLY what i need. THANK U SO MUCH.h
humm.. uh oh.. i use prettyurl  ;D ill try this mod next time..
im still gonna use it later on. it's still a fantastic mod

roco

Hi :)

Can you re-check, (@kosaic, @anakmacan, and all those who have installed Mod Pretty URLs), with a proposed solution - fix from the @dynaweb?

Quote from: dynaweb on March 12, 2010, 04:07:43 PM
Easy (but dirty) fix, dodge the htaccess rewrite by tweaking the case of the url.  Google doesnt seem to mind...

old

<a href="http://translate.google.com/translate?hl=en&amp;sl=', $txt['lang_dictionary'], '&amp;tl=es&amp;u=', $scripturl, '?topic=', $context['current_topic'], '.0.html" title="Traducción al espanol [ES]" target="_blank"><img src="', $settings['default_theme_url'], '/images/gtflags/es.png" alt="[ES]" style="border:none;" /></a>

new
<a href="http://translate.google.com/translate?hl=en&amp;sl=', $txt['lang_dictionary'], '&amp;tl=es&amp;u=', ucfirst($scripturl), '?topic=', $context['current_topic'], '.0.html" title="Traducción al espanol [ES]" target="_blank"><img src="', $settings['default_theme_url'], '/images/gtflags/es.png" alt="[ES]" style="border:none;" /></a>


So for test please check this code:

<a href="http://translate.google.com/translate?hl=es&amp;sl=', $txt['lang_dictionary'], '&amp;tl=es&amp;u=', ucfirst($scripturl), '?topic=', $context['current_topic'], '.html" title="Espanol [ES]" target="_blank"><img src="', $settings['default_theme_url'], '/images/gtflags/es.png" alt="[ES]" style="border:none;" /></a>

Thank You for your cooperation :)

Thank You, @dynaweb for your Fix :)

Regards :)
roco

kosaic

Roco & Dynaweb,

Thanks very much ! I have Pretty URL's on, and with the fix, it works perfectly !!!

I am running SMF 2.0 RC2 & Pretty URL's 1.0RC for reference.

Fixed Code:
<a href="http://translate.google.com/translate?hl=en&amp;sl=', $txt['lang_dictionary'], '&amp;tl=en&amp;u=', ucfirst($scripturl), '?topic=', $context['current_topic'], '.0.html" title="Translate into English [EN]" target="_blank"><img src="', $settings['default_theme_url'], '/images/gtflags/us.png" alt="[EN]" style="border:none;" /></a>

I appreciate you guys looking into this and fixing it !

Cheers,
K

anakmacan

oh i c so i just need to change this $scripturl into ucfirst($scripturl).
Thanksss!!!

kosaic

exactly, and works 100% perfect afterwards !

roco

Hi :)

Thanks for checking guys!
Always one problem less
and one more good tips.
;)

Yours :)
roco

anakmacan


roco

:) wow you need so much?

Ok, I see that it came out beautifully and I see a lot of work!

It looks very nice, good job

Good luck with Your Community


Regards :)
roco

Miasma

Is it possible to remove the white google bar on top of translated pages?

Anyway, nice mod.

It could be improved to something like wordpress plug-in "Global Translator".
http://wordpress.org/extend/plugins/global-translator/

What it does is making your website available in many languages.
For example when a german user google searches something, he will find your blog in his language under URL example.com/?lang=de

Example site: http://spinflipper.com/blog/?lang=pl

meteo021

Instruction for this mod is not clear enough for me. If I understand good, all I have to do is to add this:
<div style="float:right; margin:2px 1px; display:inline; vertical-align:middle; zoom:1;" charset="utf-8">
Here comes choosen set of languages
</div>
in front of this:
<td valign="middle" width="85%" style="padding-left: 6px;" id="top_subject">

I did that, but nothing happen. What I did wrong?

roco

Hi :)

I am happy to help you @meteo021
But you did not provide key information. For example, what version of the forum?

But from what you wrote, I guess that it is a 1.xx version of SMF?

There are large differences in both versions.
We're talking about a file version 1.xx Display.template.php In this model based on Tables, and version 2.0 is already div's.
From what you wrote shows that it is a 1.xx version of SMF, and that you ask about adding the code manually, I guess you want to integrate Google Translator with another style, but the modification has been installed previously?

If so, then in the directory - ./Themes/default/images/ --> should have a folder with the flags: "gflags"

Let us now turn to the code.
The div with google translator should be in the middle of the table cells, but not before it.
- After!
Like this:

<td valign="middle" width="85%" style="padding-left: 6px;" id="top_subject">

and here the div with Google Translator
.. .. ..
</td>

The code:

<td valign="middle" width="85%" style="padding-left: 6px;" id="top_subject">
<!-- Google Translator Flags by Roco -->
<div style="float:right; margin:2px 1px; display:inline; vertical-align:middle; zoom:1;" charset="utf-8">
content of Goggle Translator
</div>
<!-- End of Google Translator Flags by Roco -->
', $txt[118], ': ', $context['subject'], ' &nbsp;(', $txt[641], ' ', $context['num_views'], ' ', $txt[642], ')
</td>
</tr>';
if (!empty($settings['display_who_viewing']))


I thin thats is small problem with html ;)

If you will need to manually instal, easy:
- Download the mod and unpack.
- copy the folder "gflag" in to --> ./Themes/default/images/ so the adress mus be like this: ./Themes/default/images/gfags
- edit the Display.template.php as I showed above in the "code" (*)

(*) Instructions on how to edit and what can be found in the files: install1.xml and install2.xml, it depends on the version of the forum.

Quote
The mod will update only the default templates, for another please read install[1 or 2].xml
- and is easy for integration with different styles as well.

I hope this information will be helpful. :)



We beg you to record the necessary information, how else can I help?
Guessing? I'm not clairvoyant hehe ;)



@Miasma

QuoteIs it possible to remove the white google bar on top of translated pages?

Localy? so maby yes via client (browser + JS + CSS) Globaly? I don't think so, sorry..
You should know that what you get from Goggle Translator, it's not your party, look at the address bar in your browser.
Content is dynamically generated from your forum, but it no longer is your forum!
Content Only comes with it as a starting material for translation. Sorry ..


QuoteAnyway, nice mod.

Thank You :)

btw I wanted to create something simple that does not interfere too much in the mechanisms of the SMF and its DB...
I know what You mean. I think is posible integration of Google Translate API in to SMF like VB.
I reflected on this path, but I chose a simpler solution, because I respect people's privacy,
and this can not be ensured by using the Google API
I promise that I think about this in the near future, ok? ;)


Yours :)
roco

.

Advertisement: