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.
So this is how I got things to work. You can copy the method
execute()fromSpecialPageTranslation.phpto your custom class. This method will mark an article as translatable. Simply pass it the title of your desired article by instantiating a newTitleobject with$title = Title::newFromText( 'Title_of_my_article' );. Copy all the methods referenced by$thisto 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 namesTitle_of_my_article/1/enandTitle_of_my_article/enand commit them using the default MW API. (Be aware that1/enmarks 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.