Translation Block

Translation Block

by Paul Holden -
Number of replies: 32
Picture of Core developers Picture of Moodle HQ Picture of Moodle Workplace team Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers
I've added a new block to the Modules & Plugins database: Translate Block.

Supports multiple languages and uses the Google Translator to do the translation.

Translation result

Let me know what you think smile
Average of ratings: -
In reply to Paul Holden

Re: Translation Block

by Andy Tagliani -
Hi Paul,

the block is not there, see screenshot below!

Andy

Attachment empty.gif
In reply to Andy Tagliani

Re: Translate Block

by Helen Foster -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hi Andy,

The Translate block entry required approval before it was viewable by everyone. This has now been done.

Paul thanks for your block. approve


In reply to Paul Holden

Re: Translation Block

by Ralf Hilgenstock -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Translators
Hi Paul,

very interesting block. German translation added.
You should change the declaration forethe 'to' field. The leading and final space in the lang field will be a problem for some translators.

Under 1.9 I get the following message: Notice: Undefined property: footer in [...]/moodle/blocks/moodleblock.class.php on line 240
In reply to Ralf Hilgenstock

Re: Translation Block

by Paul Holden -
Picture of Core developers Picture of Moodle HQ Picture of Moodle Workplace team Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Ralf, thanks for spotting that. Could you try downloading the block again as I think I've fixed the problem with the undefined property. Thanks for the German translation too, and I've made the changes to the language files regarding spaces.

Helen, thanks for making it live smile
In reply to Paul Holden

Re: Translation Block

by Ralf Hilgenstock -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Translators
Hi Paul,

Ralf Krause suggested to change the 'to' to '>'. I think this is a good idea and needs no translation.
In reply to Paul Holden

Re: Translation Block

by Ralf Hilgenstock -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Translators
Hi Paul,

I just found a problem: if the translation is block is on the same page like an element with the HTML Editor, the editor is also integrated in the text field of the block and breaks the page structure.

Ralf
In reply to Ralf Hilgenstock

Re: Translation Block

by Paul Holden -
Picture of Core developers Picture of Moodle HQ Picture of Moodle Workplace team Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Ralf,

Thanks for picking that up. Could you let me know the steps I can take to reproduce this bug, and perhaps get a screen shot of what happens? That would help me to narrow down what is causing the problem.

Paul
In reply to Paul Holden

Re: Translation Block

by Ralf Hilgenstock -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Translators
Example: website administration - frontpagesettings


Attachment translation_block_editor.png
In reply to Ralf Hilgenstock

Re: Translation Block

by Paul Holden -
Picture of Core developers Picture of Moodle HQ Picture of Moodle Workplace team Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Thanks for that. I've submitted it to the Developers Forum (thread link) so we'll see what comes of it. As soon as a resolution is found, I'll update the package.
In reply to Paul Holden

Re: Translation Block - permissions

by Timothy Kane -
Module "translate" is not readable - check permissions

This is a the top of the main page in black type.

1) Where do you set or check the permission on a new plug-in?

Helen Foster says the Translate block entry requires approval before it is viewable by everyone.

2) How is that done?

I am using Moodle 1.8+ in a MAC PPC. I went into the MAC OS systems and set "admin" permission to read/write and "everyone" permission to read. Is this what I should be doing to correct this or I am I out in left field some place staring are the moon?

Thanx

Tim

In reply to Timothy Kane

Re: Translation Block - permissions

by Jan Dierckx -

Helen's statement was about the download package for the translate block plugin being viewable by everyone in the Moodle.org plugin repository. Before approval by one of the Moodle.org maintainers, plugins are only visible to the developer who uploaded it.

You don't need to change any permissions on your Moodle install to make it working. You should however remove it from the mod directory and put it inside the blocks directory. Afterwards visit the admin page of your moodle installation. The block should then be installed automatically.

HTH

In reply to Jan Dierckx

Re: Translation Block - permissions

by Gustavo Denecken H. -

Hello felows!

I'm writting you from Chile. Here this about moodle is something very new... I never realise that moodle was so complete and powerful!

I just installed de translator block, but I have this error message when I try to translate something

"Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in /home/wi490402/public_html/intranet/blocks/translate/ajax_translate.php on line 9"

Can you give me some help please!

Best regards,

Gustavo

In reply to Gustavo Denecken H.

Re: Translation Block - permissions

by Gustavo Denecken H. -

Hello,

I've just solve this problem by setting in 0 instead 1 the value that appears in the line 9 of the ajax_translate.php file...

Now I have another doubt ... How can I change the size of the text area where you write the text that you want to translate?

Because I'm using a theme that makes that the text area look too big...

thanks!!

Gustavo

In reply to Paul Holden

Re: Translation Block

by Gustavo Denecken H. -

Hello!!

How can I change the size of the Input text area, because is to big for mi purpose.

Thanks,

Gustavo

In reply to Gustavo Denecken H.

Re: Translation Block

by Paul Holden -
Picture of Core developers Picture of Moodle HQ Picture of Moodle Workplace team Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Gustavo,

If you open block_translate.php, you'll find a line near the end of the script that looks like this:

<textarea cols="30" rows="3" id="translate_input"></textarea>

The cols and rows attributes determine how big the input text area is.

However it could be you are experiencing the problem mentioned by Ralf above, which is detailed here.

Paul
In reply to Paul Holden

Re: Translation Block

by Gustavo Denecken H. -

Hi Paul, and thanks for your help.

But, I understand that those attributes are referred about how mach text can I put into the text area, and I want to change the size (in pixels) of the text area.

(Sorry for my english!! jaja)

Gustavo

In reply to Gustavo Denecken H.

Re: Translation Block

by Paul Holden -
Picture of Core developers Picture of Moodle HQ Picture of Moodle Workplace team Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Gustavo,

Those attributes do control the size of the input area, try changing them and you'll see wink

For instance if you want to make it taller, increase the rows attribute.

Paul
In reply to Paul Holden

Re: Translation Block

by paulo marques -

when i press translatethan i have this error message:

Fatal error: Call to undefined function curl_init() in C:\xampp\htdocs\moodle\blocks\translate\ajax_translate.php on line 6

...any idea to solve the problem???

i have moodle 1.7

thanks

In reply to Paul Holden

Re: Translation Block

by Alex DePena -
I just did a fresh install of Moodle 1.8.4 and then an install of the the translate block. No errors on install. Server is using PHP5.

When I try to use the translate block I get the following error:

Notice: Undefined offset: 1 in /webdocs/sandbox/moodle/blocks/translate/ajax_translate.php on line 14

I do not get any translation output.

Is there anything I can do to help debug this issue?

Thanks


In reply to Alex DePena

Re: Translation Block

by Luca Navone -
Hy, Alex. I have a little different problem, but similar: I did install translate block one month ago and every things work perfectly (moodle 1.8.3). Two week ago I cannot get any translation output. In the administration page there is an option for activate ajax. It would be useful? I don't try...

Luca
In reply to Luca Navone

Re: Translation Block

by Paul Holden -
Picture of Core developers Picture of Moodle HQ Picture of Moodle Workplace team Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Alex, Luca,

Google have recently slightly changed how the translations are returned to a browser. The following change to ajax_translate.php should fix your problem:

Around line 13, you'll find the following line:

preg_match('#<div id=result_box dir=ltr>(.*?)</div>#s', $html, $out);

Change it to the following:

preg_match('#<div id=result_box dir="ltr">(.*?)</div>#s', $html, $out);

Hopefully that'll solve both your problems - let me know! smile

Paul
Average of ratings: Useful (1)
In reply to Paul Holden

Re: Translation Block

by Luca Navone -
Hi, Paul. With your suggestion the behavior was better but don't perfect...
Now when I ask the traduction (in Italian, for example) of "green" I get the same thing: "green". Also with other languages....
Before I cannot see nothing.
But the way you show is right: it is a google change in some parameters.

Thank you very much

Luca
In reply to Paul Holden

Re: Translation Block

by Luca Navone -
Sorry, I said a false thing: with your suggestion the block works properly; probably I haven't refresh the cache of my browser and so the output was no perfect. Now that I restart my browser all is right!!!

Thank You,

Luca.
In reply to Luca Navone

Re: Translation Block

by jim williams -
Hello all

I have uploaded to the blocks folder, all set up fine, but after I added it to my page and entered text nothing is translated. Am I missing something?


Any help would be great.

Jim
In reply to jim williams

Re: Translation Block

by Paul Holden -
Picture of Core developers Picture of Moodle HQ Picture of Moodle Workplace team Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Jim,

You may have to make the change I mentioned in this post.

Hope this helps.

Paul
In reply to Paul Holden

Re: Translation Block

by Edward Higgs -
Hi Paul,


I have had this block working perfectly since April 2008, accross serveral Moodle Sites including versions 1.8 and 1.9

Between September 2009 and now (November 2009) it has suddenly stopped working i.e. noting appears in the translation output box.

Do you know if Google have once again changed "how the translations are returned to a browser"


Any help or advice greatly appreciated.

Thanks

Eddie

In reply to Edward Higgs

Re: Translation Block

by Paul Holden -
Picture of Core developers Picture of Moodle HQ Picture of Moodle Workplace team Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Edward,

Indeed, Google have changed how the translations are returned.

You'll need to update the global Translator block config - from your Site Administration panel, select Modules > Blocks > Translator and paste the following into the block_translate_pattern field:

#<span title=".*" Xonmouseover=".*'" Xonmouseout=".*'">(.*?)</span>#s

This works for now (until they change the result page again, of course!) approve

Edit: Moodle has eaten my formatting - exclude the X's from the string I gave above.
In reply to Paul Holden

Re: Translation Block

by Michael de Raadt -
Hi Paul,

I'm not getting any translated text from the block. I can tell you cURL is enabled and Ajax is working. Perhaps the Google API has changed?

By the way, I don't have a global config page. There is no global config HTML file with the block code I just downloaded.

Any advice?

Michael;
In reply to Michael de Raadt

Re: Translation Block

by Michael de Raadt -
Hi Paul and All,

I've found that Google's translate_t Ajax API no longer works. Google offers a JavaScript API and I was able to use that to get this block going.

I've attached the code to this message for others to test.

Michael;
In reply to Michael de Raadt

Re: Translation Block

by Camilo Rivera -
Any alternatives for Moodle 2? I couldn't find anything at the plugins site. I also looked for a TinyMCE plugin and it was outdated too.
Average of ratings: Useful (1)