langdoc.php - a tool for online docs and help files translation

langdoc.php - a tool for online docs and help files translation

by David Mudrák -
Number of replies: 36
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
Hi!

I've written a small script that can be used for online translation of /docs and /help files. Maybe you can find it useful for your needs wink

langdoc.png

How to install:
  1. download attached langdoc.php
  2. copy it into your /admin Moodle directory
  3. go to http://yourmoodle.url/admin/langdoc.php

Average of ratings: -
In reply to David Mudrák

Re: langdoc.php - a tool for online docs and help files translation

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Yay!  We've needed that for ages - that's going straight into CVS!
In reply to Martin Dougiamas

Re: langdoc.php - a tool for online docs and help files translation

by János Fehér -
Can we use it on moodle.org? I still waiting for an account to the CVS =)
In reply to János Fehér

Re: langdoc.php - a tool for online docs and help files translation

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Sorry, I never saw any mail from you ... just found it now though!  blush Will mail you back.
In reply to Martin Dougiamas

Re: langdoc.php - a tool for online docs and help files translation

by János Fehér -
It's interesting...
2005-02-11 15:10:55 1CzbVT-000HMe-0i <= feher.janos@mindworks.hu H=adsl215151.vnet.hu (golem.devel.mindworks.hu) [62.77.215
.151] P=esmtp S=1618 id=1108131037.2648.30.camel@ganja.devel.mindworks.hu
2005-02-11 15:10:57 1CzbVT-000HMe-0i => martin@moodle.org R=dnslookup T=remote_smtp H=moodle.org [69.93.78.186] X=TLSv1:AES
256-SHA:256
2005-02-11 15:10:57 1CzbVT-000HMe-0i Completed
The letter was:
Hello Martin, Near half year ago I've sent you a letter about Hungarian translation of Moodle but you haven't answered me. I try to actualize and organize the translation, but I should get a CVS account (aries69 at SF) to update the language files. Can you help me? Bests,
In reply to János Fehér

Re: langdoc.php - a tool for online docs and help files translation

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Just because mail gets into my mailbox doesn't mean I always see it! tongueout You should see the size of that thing! Anyhow, I replied today ... you should contact Karoly who is coordinating Hungarian.
In reply to Martin Dougiamas

Re: langdoc.php - how to handle CVS tags?

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
Hi folks

I'd like to ask you - should I care about some CVS tags of langdoc.php or is this Martin's job? I've read developer manual but being still CVS beginner I don't understand very much how langdoc.php will became part of official (pre)release.

Thanks for any explanation.

David
In reply to David Mudrák

Re: langdoc.php - how to handle CVS tags?

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Unless there's a big problem with it it will be in Moodle 1.5. Is it all working correctly now?
In reply to David Mudrák

Re: langdoc.php - a tool for online docs and help files translation

by koen roggemans -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Translators
Going to test this immediately. Thanks a lot!
In reply to koen roggemans

Re: langdoc.php - a tool for online docs and help files translation

by koen roggemans -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Translators
Works great. I love the preview button. With firefox tidy installed, you can immediately check the xhtml-compliance as well, without the need having the site on the internet or to click several times and that for  both English and translated file smile

 I just  changed the (!) for untranslated files in *** for visability, but I might as wel need new glasses big grin
In reply to David Mudrák

Re: langdoc.php - a tool for online docs and help files translation

by Mitsuhiro Yoshida -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Translators
Thank you, Great work!
I really love this new cool feature. wink
In reply to David Mudrák

Re: langdoc.php - a tool for online docs and help files translation

by Ling Li -
I have used it on my 1.4.3 installation and it works fine except one problem.

I found the script create a new empty file when I choose a file not existing from the dropdown list, no matter I press save button or not. If I haven't write anything, I will have to delete the empty file by hand sometime later or it prevent the English one being displayed. Maybe it's better not save the empty file.
In reply to Ling Li

Re: langdoc.php - a lot of empty files

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
I know about this problem. It is caused by touch() function (langdoc.php tries to create non-existing file in order to check permissions). I'll try to change this behaviour ASAP.
In reply to David Mudrák

Svar: langdoc.php - a tool for online docs and help files translation

by Anders Berggren -
Very cool! Thanks.
Anders, Swedish translator.
In reply to David Mudrák

Re: langdoc.php - PATCH #1

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
To fix Ling Li's bugreport I've patched langdoc.php. Empty files doesn't remain in the directory now smile As long as I haven't got CVS write access I attach patched version to this post.

Thanks all for your feedback!

David (http://moodle.cz)
In reply to David Mudrák

Re: langdoc.php - PATCH #1

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Hi, David!  I made quite a few changes to the script when I checked it in, so this is out of date already!  tongueout

I've given you CVS access to it so make fixes there!  Thanks!
In reply to Martin Dougiamas

Re: langdoc.php - PATCH #1

by Petr Skoda -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers
...looking at the code array $options is not initialized wink
In reply to Petr Skoda

Re: langdoc.php - code array $options is not initialized

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
Ahoj

Sorry for this. Being newbie to Moodle coding style I forgot this stuff. Good job, Security Officer wink
In reply to Martin Dougiamas

Re: langdoc.php - PATCH #1 committed

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
Done - the patched version is in CVS. I hope it is clean and without bugs now. Thanks for your help!
In reply to David Mudrák

Re: langdoc.php - PATCH #1 committed

by Nicolas Martignoni -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hi,

Many, many thanks for this tool !

May I suggest to the translators that ANY file in the help folder begins with this string on the first line:

<!-- Version: $Id$ -->

and to set the $filetemplate var in langdoc.php accordingly by default. This way we could know rapidly when the last changes were made. It could be very useful big grin

Thanks again !

Nicolas, french translator
In reply to David Mudrák

Re: langdoc.php - a tool for online docs and help files translation

by Lasha Altunashvili -
Hi,
Thanks a lot for this script. It's great.

I change it a little bit and added editor support. It is much easier for other translators to do the translation in editor rather then in HTML.
Lasha


Attachment langdoc.JPG
In reply to Lasha Altunashvili

Re: langdoc.php - a tool for online docs and help files translation

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Sorry, but this is not a good idea, because the editor will produce a lot of messy HTML code with styles in the help files that will need to be cleaned up.

The help files must remain free of all styles so that they can be used in different contexts.
In reply to Martin Dougiamas

Re: langdoc.php - a tool for online docs and help files translation

by Lasha Altunashvili -
Thanks for your reply Martin. You are right, WYSIWYG editors have there drawback, however you can always switch to the html source editing and compare original to the translated one. HTML editor may encourage other people to translate entire help. As you know not all the help files are translated to other languages (e.g. Russian). I think completely translated help is more valuable than extra several Kb of HTML code.

Anyway this script helps us to move more quickly and other people may find it useful as well. We will make sure all the doc/help files are clean from any extra code.

Thanks again
Lasha
In reply to Lasha Altunashvili

Re: langdoc.php - a tool for online docs and help files translation

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
Hi Lasha
I don't think so - IMHO it is not a  good idea to allow wysiwyg in langdoc.php (for the same reasons as Martin noted). And I don't think that HTML editor would encourage other people to translate help - at least not in my country wink But maybe you will find a way how to keep the code clean...
And the last note: my experiences show me it is not necessary to have whole help and doc translated. Users don't read it anyway - they always try to find their own solutions wink

david
In reply to David Mudrák

Re: langdoc.php - a tool for online docs and help files translation

by Lasha Altunashvili -

Hello David,

I like this one "Users don't read it anyway" smile.

About the way to keep it clean. We are copying the original html to translation box, changing it to HTML and replacing the English text with our translation. it works pretty well.

Our problem is that several translation team members are not familiar with HTML and they prefer to work in editor.

Lasha

In reply to Lasha Altunashvili

Re: langdoc.php - a tool for online docs and help files translation

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
If they are not familiar with HTML then it seems even more likely that using the editor will cause problems in the code.

It doesn't take long to learn what the HTML codes do, and they don't need to change them anyway, just avoid them.
In reply to David Mudrák

Re: langdoc.php - a tool for online docs and help files translation

by Jaime Villate -
Very nice. Thanks David!

But I have a problem:

When I translate a page that includes some php script, it is
replaced by the result of the script.

For example, in the Installation FAQ (faq.html) there is a place
where it is suggested that the user writes the script

<?PHP phpinfo() ?>

to find out what PHP version is running. When I save the changes
to my translation, that line is replaced by the whole outpout
from that command (that does not happen if you edit the file
using the file module).
In reply to Jaime Villate

Re: langdoc.php - should we allow PHP included?

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
Hi Jaime

Thanks for your report! The important question has arised: are <? <php and <PHP tags allowed to be included in help and doc files? Are they needed somewhere? The current version of langdoc assumes the translator to be responsible for the HTML code so it allows put these tags. But we can let some filters to be applied before saving the code.
One has got possibility to include these tags with & lt;php syntax (how is it called - HTML entities?) so I would prefer not to filter anything and trust the translators...

David
In reply to David Mudrák

Re: langdoc.php - should we allow PHP included?

by Jaime Villate -
Yes, you are right.

I did not explain the problem correctly. The current bug is:
when the user first translates the file, he will use entities
&lt; and &gt; when he wants to refer to some tag.

If he tries to edit the translated file again, the
&lt; and &gt; entities in the original file are shown
as < and > in the translation form.
When the user saves the file, even if no changes were done, the
file will be spoiled (the literal tags that were initially
written correctly using entities will be transformed into real tags, causing trouble).

Also. I have not checked it yet, but a single backslash in the original
file should not become a double backslash when one saves a new
version of the file (that was a bug that we already fixed in
the file module).
In reply to Jaime Villate

fix for langdoc.php

by Jaime Villate -
Translators can see the problem I was referring to if the try
to look at any of the mods.html files, for instance help/hotpot/mods.html, using langdoc.php

You can compare what langdoc.php shows you with the real content
of the file:
http://cvs.sourceforge.net/viewcvs.py/moodle/moodle/lang/en/help/hotpot/mods.html?rev=1.4&view=markup

Due to that bug, there are several translated files,
in several languages, which are wrong. For instance, look at the
Dutch translation of the file above (no need to know Dutch;
just compare the URL in the first line):

http://cvs.sourceforge.net/viewcvs.py/moodle/moodle/lang/nl/help/hotpot/mods.html?rev=1.1&view=markup

The file I send in attachment solves the bug.
In reply to Jaime Villate

Re: fix for langdoc.php

by koen roggemans -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Translators
Yes, I've been fooled by that one today verlegen.
So it's the editor causing trouble. Thanks for pointing that out.

I've found about 18 affected files over all language packs in ja/ja_utf8, lt and sv.

I'll fix them asap
In reply to koen roggemans

Re: fix for langdoc.php

by Jaime Villate -
> I've found about 18 affected files over all language packs in
> ja/ja_utf8, lt and sv

Good job, Koen. You only missed the Finish language (fi) where
instead of "localhost" you should look for occurrances of
"http://moodlepalvelut.fi" which most be the server where
the Finish team has been running langdoc.php

In reply to Jaime Villate

Re: fix for langdoc.php

by koen roggemans -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Translators
They don't make it easy up north. Thanks Searched for http in mods and found 16 more
In reply to Jaime Villate

Re: langdoc.php - prevent PHP parsing

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
Thanx Jaime for his report again! There has been a bug in langdoc.php: The content of textarea edit fields has been obtained by include() function and thus been parsed by PHP. I've just changed the code to read the files directly by fread() without PHP processing. I'm going to do some tests and will commit patched version to CVS today.

D.