I am working on implementing a per page language selector in MediaWiki as a part of my GSoC project. The first patch is almost ready, waiting for a few reviews and then we will have page language selection in MediaWiki.
Introduction- Why is it required?
The answer lies in internationalization of wikis. To build multilingual wikis, it is very important that the user should be able to share content in any language that he wants to and then it can be translated to other languages.
The MediaWiki Translate extension has greatly contributed to the internationalization of wikis. Translation administrators can translate pages and then they can be used by users to view it in their native or preferred language.
But this major bug stops wikis from being purely multilingual. How? Currently wikis have one default Content language and it is assumed that all pages are written in the same. But take a case where the Content language is English and the user wants to write a page in say Dutch. It isn’t possible. But if there is a way to allow the user create a page in any language, and allow Translation administrators to translate it from that to other languages, this leads to the formation of truly multilingual wikis. This way information can be shared among people without any language bounds.
We started off with the idea of adding an entry in the database which stores the page language, but it wasn’t as easy as this. We had a lot of questions to be answered.
It needs to be a property for the whole page so a
There are a few questions that needed answer when we started:
- How should it be integrated with all the existing wikis?
- How should it handle defaults?
- Need to integrate with API?
- What should be the UI
Starting off with the first version
So the first version had to solve all the issues above. The idea was to keep the default for page language as null and null corresponds to the default wiki language in the code. It solves the issue of running the script for thousands of pages on a wiki to set the value in DB. Next was the UI part. My mentors suggested to keep it as simple as possible to start with and it was important to make it not too hidden and not too visible at the same time. It was built as a Special Page to change the page language. The UI includes 2 options- default and user defined, the default option simply sets the language to null while the user defined gives the user a drop-down list to select the language.
To make the UI simpler, a link is added from the
?action=info page to a SpecialPage’s subpage with name of the page whose language is being changed. It also fills the form’s page name field by itself making it easier to use. A successful change in language redirects the user to the page whose language is changed. A very important part of the patch is who should get the permission of changing the page language. It isn’t answered yet, we didn’t assign the permissions to anyone as yet. The wiki owner needs to assign permissions to specific groups currently.
Another important part was to log all the changes. All the changes are logged to Special:Log using a special log formatter which displays the from and to language of translation in the user’s language. One thing that we considered is a change from the default to the Content Language should be considered valid and we took care of that as well. We marked the default as LanguageName[default] in Log.
Some issues faced
There were some issues faced while building this up, the first one being the Title and ContentHandler class are somewhat complexly written so it was important to make the code work without messing up with them. My mentor took up the task of rewriting the functions in these classes and I concentrated on making the patch work with minimal changes in these classes. One major issue in this patch is that API methods of getting page language wouldn’t work with the DB. I made a simple patch which addresses this issue but included it only as a dependency to Robin’s(my mentor) patch.
Things to look at now
A few important things need to be addressed after this patch:
- What happens when the content language changes to the pages whose language is default?
- Who should have the permissions for changing page language?
- Need to have a control on what pages allow a language to be set.
- Use the Universal language selector instead of the dropdown
- Better, more accessible UI maybe on the
- How should Translate extension behave with this? Should it have a Translate From button as well? Since all users can’t read all languages.
It is very important to solve all these issues before this function becomes an integral part of MediaWiki. Looking forward to solve all these issues and make a good contribution to MediaWiki.