Question

I write hundred of articles into a MediaWiki (version 1.20.2) through its API using a self-programmed PHP script that depends on WikiMate. At the moment, the articles are only written in English. But I want to translate them using the Translate extension, so I have to approve every single article for translation.

For every article there is already an English and a French document, so is there any automated way to write articles in English (default) and the translated article (in French) at once using the API? The Translation should be compatible to the Translate extension.

Was it helpful?

Solution 2

So this is how I got things to work. You can copy the method execute() from SpecialPageTranslation.php to your custom class. This method will mark an article as translatable. Simply pass it the title of your desired article by instantiating a new Title object with $title = Title::newFromText( 'Title_of_my_article' );. Copy all the methods referenced by $this to your custom class as well. E.g. the method $this->markForTranslation(..) and its dependencies.

After calling the execute() method, an article is marked for translation so you can commit the translated article. I simply do this by giving the English-translated article the names Title_of_my_article/1/en and Title_of_my_article/en and commit them using the default MW API. (Be aware that 1/en marks the translated section that you commit, so you will commit the whole article just as a translated section)

Sadly, the Translate extension is poorly documented so it is very hard to understand how things work.

OTHER TIPS

What do you mean "approve every single article for translation"? To do the "mark for translation" action, which adds the <!--T:1--> tags? Currently there's no web API to do this, unfortunately.

If you are very sure that the pages in both languages have a very similar structure, you can try writing your own script that would import them chunk by chunk, but there are no clever built-in options for that, either.

If you code any solutions for that, it would be very nice of you to share them :)

(Comment: I am one of the developers of the Translate extension.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top