User:SPQRobin/Page language

From MediaWiki.org
Jump to: navigation, search

As part of Extension:Translate/Usability improvements 2014.

What[edit]

Backend basics:

  • Assumption 1: PCL should be defined in the database.
  • Assumption 2: PCL is a property of a page, not of a specific revision.
  • The value is obviously a language code.

Other backend:

  • How to handle the default value? Should we include a selector option "Use default language", which would be what getPageLanguage() returns normally?
  • How does it interact with other PCL definitions, especially the hook (by which extensions, like Translate, can alter the PCL. Do they need to be able to disable setting the PCL through the selector?
  • A way to define the PCL as the user language ($wgLang)? E.g. value "user" in DB, instead of a language code.

Maybe a selector with options

  • Use default page content language
  • Use user interface language
  • (languages...)

Implementation[edit]

I have a basic idea currently:

  • Having a SQL entry for a page. I think it should be possible to change it in a particular revision.
  • The language if not set should be the default wiki language.
  • There should be an API method also for getting the page language.

Edge cases/doubts:

  • What to do if the page is a /fr subpage and user sets it as "de" language?
  • What to do if a PCL was already set e.g. by an extension like Translate?

GUI[edit]

  • Setting the value by using something similar to the Universal Language Selector. --User:Kunalgrover05

Progress[edit]

  • Discarded the idea of page_props- Aim is to build a system which is a fundamental property of the page similar to ID.
  • Understood the working of databases in core.
  • Set up a new field in the database in the pages table. Working only with MySQL currently.
  • Made a function to update the value of the page language for all the existing Wiki pages(which is currently set as the default wiki language) in the table.
  • Created a special page to change language for a page- initial idea for implementation.
  • Submitted the first patch for implementation of PageLanguageSelector
  • Added code for getting the page language using API
  • Added code for logging into DB and for Special:Log
  • Changing language redirects to the page it changes language for.
  • Added options on page if user wants to use default wiki language.
  • Added patch to make it compatible with MySQL|Postgres|SQLite|Mssql|Oracle

First patch[edit]

  • Finished the first patch- Waiting to be merged.
  • Adds DB part for new and existing wikis.
  • Minor changes in Title.php to read language from DB
  • Logged in users can change language.
  • Special:PageLanguage to set the language for a page.
  • Added logging
  • Links from ?action=info page to subpage of Special:PageLanguage with prefilled forms if the user has necessary permissions
  • Made the feature optional using a configuration variable. Made the SpecialPage's and also logging part's visibility dependent on it.

Improvements added in new patches[edit]

  • Server side purging a page on changing language
  • Reading page language from API fetches from DB
  • Checking edit permissions if any user wants to change language
  • Made a patch which ensures that it isn't read from DB multiple times
  • Working with a PageLanguage class which serves both Special:PageLanguage and API for setting page language
  • Added support for usedb variable in Robin's patch
  • Errors for API and Special:PageLanguage using a Status object.
  • Change interface from XML type selector to Universal Language selector.
  • Translate extension should display the source language
  • Showing page language change log on Special:PageLanguage
  • Translate extension should create the correct subpage for each page depending on the page language.

Gerrit Patches[edit]

https://gerrit.wikimedia.org/r/#/c/135312/ (Merged)

https://gerrit.wikimedia.org/r/#/c/143015/ (In review)

https://gerrit.wikimedia.org/r/#/c/143049/ (In review)

https://gerrit.wikimedia.org/r/#/c/143025/ (In review)

https://gerrit.wikimedia.org/r/#/c/137915/ (In review)

See also[edit]