MediaWiki-Docker/Extension/Translate

From mediawiki.org
Jump to navigation Jump to search

Follow Quickstart instructions at MediaWiki-Docker page. Once MediaWiki is running and available at http://localhost:8080, then copy the following code into a script file in the directory where you installed MediaWiki and run it. You can also copy paste it directly into the terminal but beware of interactive_comments being off.

Before running, update the script and remove any extensions or themes that you have already cloned.

# If you have already customised this file, merge it manually instead of overwriting it.
tee docker-compose.override.yml <<'EOF'
version: '3.7'
services:
  mediawiki:
    # On Linux, these lines ensure file ownership is set to your host user/group
    user: "${MW_DOCKER_UID}:${MW_DOCKER_GID}"
  mediawiki-web:
    user: "${MW_DOCKER_UID}:${MW_DOCKER_GID}"
  elasticsearch:
    image: docker-registry.wikimedia.org/dev/stretch-elasticsearch:0.0.1
    volumes:
      - esdata:/usr/share/elasticsearch/data
    environment:
      - discovery.type=single-node
    ports:
      - 9200:9200
      - 9300:9300
volumes:
  esdata:
EOF

# Make sure new services have been created
docker-compose up -d --force-recreate

# Should have some skin to make it less ugly
git clone "https://gerrit.wikimedia.org/r/mediawiki/skins/Vector" skins/Vector
git clone "https://gerrit.wikimedia.org/r/mediawiki/extensions/Elastica" extensions/Elastica
git clone "https://gerrit.wikimedia.org/r/mediawiki/extensions/Translate" extensions/Translate
git clone "https://gerrit.wikimedia.org/r/mediawiki/extensions/UniversalLanguageSelector" extensions/UniversalLanguageSelector

# This will overwrite composer.local.json if it exists.
# If it already exists, merge it with this one.
tee composer.local.json <<'EOF'
{
	"extra": {
		"merge-plugin": {
			"include": [
				"extensions/Elastica/composer.json",
				"extensions/Translate/composer.json"
			]
		}
	}
}
EOF

tee -a LocalSettings.php <<'EOF'
wfLoadSkin( 'Vector' );
wfLoadExtensions( [ 'Elastica', 'Translate', 'UniversalLanguageSelector' ] );
$wgTranslateTranslationServices['TTMServer'] = [
	'type' => 'ttmserver',
	'class' => 'ElasticSearchTTMServer',
	'cutoff' => 0.75,
	'public' => true,
	'config' => [ 'servers' => [ [ 'host' => 'elasticsearch', 'port' => 9200 ] ] ],
	'timeout' => 8,
	'use_wikimedia_extra' => true,
];
$wgGroupPermissions['user']['translate'] = true;
$wgGroupPermissions['user']['translate-messagereview'] = true;
$wgGroupPermissions['user']['translate-groupreview'] = true;
$wgGroupPermissions['user']['translate-import'] = true;
$wgGroupPermissions['sysop']['pagetranslation'] = true;
$wgGroupPermissions['sysop']['translate-manage'] = true;
$wgTranslateDocumentationLanguageCode = 'qqq';

EOF

docker-compose exec mediawiki composer update
docker-compose exec mediawiki php maintenance/update.php --quick
docker-compose exec mediawiki php extensions/Translate/scripts/ttmserver-export.php

See https://github.com/Nikerabbit/mediawiki-docker-scripts if you want to fully automate this setup.