Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Go Go Gadget Gadgets
{
"af": "popups",
"as": "Navigation_popups",
"av": "popups",
"az": "popups",
"azb": "popups",
"be": "popups",
"bg": "Navigation_popups",
"bh": "Navigation_popups",
"bn": "Navigation_popups",
"br": "Popups",
"bs": "Navigation_popups",
"ca": "Navigation_popups",
"da": "Popups",
"de": "navigation-popups",
"el": "popupdelay",
"en": "Navigation_popups",
"eo": "Popups",
"es": "Navigation_popups ",
"fa": "popups",
"fi": "popups",
"fr": "Popups ",
"gag": "popups",
"gl": "Navigation_popups",
"gom": "Navigation_popups",
"he": "popup",
"hi": "Navigation_popups",
"id": "NavPopups",
"ilo": "Navigation_popups",
"ja": "Navigation_popups",
"ka": "Navigation_popups",
"kk": "Navigation_popups",
"kn": "Navigation_popups",
"ko": "Navigation_popups",
"min": "NavPopups",
"mr": "Navigation_popups",
"ms": "Navigation_popups",
"mzn": "popups",
"nl": "Navigatie popups",
"oc": "Popups",
"or": "Navigation_popups",
"pl": "Navigation popups ",
"pnb": "Navigation_popups",
"ps": "Navigation_popups",
"pt": "Navigation_popups",
"ro": "popups",
"ru": "popups",
"simple": "Navigation_popups-API",
"sq": "Navigation_popups",
"sr": "Popups",
"ta": "Navigation_popups",
"tcy": "Navigation_popups",
"test": "Navigation_popups",
"test2": "Navigation_popups",
"te": "Navigation_popups",
"tg": "popups",
"th": "Navigation_popups",
"tl": "Navigation_popups",
"tr": "Navigation_popups",
"ur": "Navigation_popups",
"vec": "Popup",
"yi": "NavigationPopups",
"zh": "Navigation_popups"
}
<?php
$wikipediasDblist = $_SERVER['argv'][1];
$wikipedias = file( $wikipediasDblist, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES );
$wikipediasLength = count( $wikipedias );
$result = [];
foreach ( $wikipedias as $i => $wikipedia ) {
$lang = str_replace( 'wiki', '', $wikipedia );
// Silently ignore 404s, say.
$response = @file_get_contents( "https://${lang}.wikipedia.org/wiki/MediaWiki:Gadgets-definition?action=raw" );
$matches = [];
preg_match( '/\* (.*[Pp]opup.*)\[/', $response, $matches );
if ( $matches ) {
$result[ $wikipedia ] = $matches[1];
}
echo "${i} of ${wikipediasLength} done...\n";
}
file_put_contents(
'go_go_gadget.json',
json_encode( $result, JSON_PRETTY_PRINT )
);
{
"af": "popups",
"av": "popups",
"az": "popups",
"azb": "popups",
"be": "popups",
"br": "Popups",
"da": "Popups",
"de": "navigation-popups",
"el": "popupdelay",
"eo": "Popups",
"es": "Navigation_popups ",
"fa": "popups",
"fi": "popups",
"fr": "Popups ",
"gag": "popups",
"he": "popup",
"id": "NavPopups",
"min": "NavPopups",
"mzn": "popups",
"nl": "Navigatie popups",
"oc": "Popups",
"pl": "Navigation popups ",
"ro": "popups",
"ru": "popups",
"simple": "Navigation_popups-API",
"sr": "Popups",
"tg": "popups",
"vec": "Popup",
"yi": "NavigationPopups"
}
<?php
$wikipediaToGadgetMap = json_decode( file_get_contents( 'go_go_gadget.json' ) );
$result = <<<EOF
<?php
// Generated by go_go_gadget_export.php.
'wgPopupsConflictingNavPopupsGadgetName' => [
EOF;
foreach ( $wikipediaToGadgetMap as $wikipedia => $gadget ) {
if ( $gadget !== 'Navigation_popups' ) {
$result .= "\t '${wikipedia}' => '${gadget}',\n";
}
}
$result .= "],\n";
file_put_contents( 'InitialiseSettings.php', $result );
<?php
// Generated by go_go_gadget_export.php.
'wgPopupsConflictingNavPopupsGadgetName' => [
'af' => 'popups',
'av' => 'popups',
'az' => 'popups',
'azb' => 'popups',
'be' => 'popups',
'br' => 'Popups',
'da' => 'Popups',
'de' => 'navigation-popups',
'el' => 'popupdelay',
'eo' => 'Popups',
'es' => 'Navigation_popups ',
'fa' => 'popups',
'fi' => 'popups',
'fr' => 'Popups ',
'gag' => 'popups',
'he' => 'popup',
'id' => 'NavPopups',
'min' => 'NavPopups',
'mzn' => 'popups',
'nl' => 'Navigatie popups',
'oc' => 'Popups',
'pl' => 'Navigation popups ',
'ro' => 'popups',
'ru' => 'popups',
'simple' => 'Navigation_popups-API',
'sr' => 'Popups',
'tg' => 'popups',
'vec' => 'Popup',
'yi' => 'NavigationPopups',
],
@framawiki

This comment has been minimized.

Copy link

@framawiki framawiki commented May 3, 2017

For the record : https://phabricator.wikimedia.org/T164044
wiki suffix is missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment