Release status: stable
|Description||Link different language versions of a page by using the page title.|
|Author(s)||Gabriel Birke, Addshore|
|Latest version||Continuous updates|
|Compatibility policy||release branches|
|License||GNU General Public License 2.0 or later|
Translate the Cognate extension if it is available at translatewiki.net
|Check usage and version matrix.|
|Open tasks · Report a bug|
The Cognate extension creates a central store where the page titles for a group of sites are stored. It can then generate interwiki links across wiki projects in cases where the titles are the same. It was developed to solve the "Centralize interwiki language links for Wiktionary" task.
"Cognate" is a linguistic concept, referring to words in different languages developed from the same origin. This means that this extension is misnamed—since this extension links pages with the same title across wikis, a proper name would be “Homograph”.
Assumptions and restrictions
- Pages must be in one of the standard MediaWiki namespaces.
- Page titles are the same across languages (with some simple normalization applied).
- Sites should have the same interwiki structure for language links.
- Pages should not contain inter language links in wikitext as these will override the link provided by Cognate.
- Unexpected hash conflicts are unlikely but could occur, and would result in unexpected language links.
How it works
Very simple title normalization (reduction to ASCII) occurs within the extension. This can be seen in the StringNormalizer class.
Initially the amount of normalization is very small. Requests can be made to expand this and will be added on a case by case basis.
|Hello…||Hello...||The raw string contains an ellipsis character. This is normalized to three . characters|
|lepelle’||lepelle'||The normalized string has a normalized apostrophe.|
Part of the hash is then stored in the database in a BIG_INT field for efficient lookups.
There are roughly 18,446,744,073,709,551,615 possible values.
As titles that require links are assumed to be the same post normalization, they will result in the same hash and thus the same Int stored in the database.
Some sample data might look as follows when loading the "Foo..." page on enwiktionary.
|Wiki||Title||Hash Int||Normalized Hash Int||Notes|
|frwiktionary||Foo…||-7435652355441782233||395730596998145766||Matched row, even though the pre normalized title includes the ellipsis character.|
It is possible to overwrite the automatic links provided by Cognate, simply by adding one or more interwiki links in the page.
That also means that to make Cognate work when the extension is deployed, the pages should not contain inter language links in their wikitext.
The extension can be tested on beta wiktionary sites:
These sites are linked together using the Cognate extension with added interwiki sorting provided by the InterwikiSorting extension.
- Download and place the file(s) in a directory called
- Add the following code at the bottom of your LocalSettings.php:
wfLoadExtension( 'Cognate' ); # Settings used in WMF production # Use the external cluster 'extension1' and dbname 'cognate_wiktionary' $wgCognateDb = 'cognate_wiktionary'; $wgCognateCluster = 'extension1'; # Only work on the main namespace $wgCognateNamespaces = [ 0 ];
- Run the update script which will automatically create the necessary database tables that this extension needs.
- Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
- Populate the sites table by running the populateCognateSites.php maintenance script. Sites must already exist in the MediaWiki sites table with the correct groupings.
php ./maintenance/populateCognateSites.php --site-group=wiktionary
- Populate the page and title tables by running the populateCognatePages.php maintenance script.
|This extension is being used on one or more Wikimedia projects. This probably means that the extension is stable and works well enough to be used by such high-traffic websites. Look for this extension's name in Wikimedia's CommonSettings.php and InitialiseSettings.php configuration files to see where it's installed. A full list of the extensions installed on a particular wiki can be seen on the wiki's Special:Version page.|