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.