ProleWiki:Maintenance/Adding languages: Difference between revisions

From ProleWiki, the proletarian encyclopedia
(Changing order of steps)
m (Added Flow to list of extensions which require manual intervention.)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
Here we will be following a step-by-step tutorial on how to add new languages to ProleWiki. We will use a non-existent "aa" language code as an example, but it should be changed to the language that is being included (e.g.: <code>en</code> for English, <code>fr</code> for French, <code>ru</code> for Russian, etc.). We can check the existing language on Wikipedia as a reference for its language code.
The following is a step-by-step tutorial on how to add new languages to ProleWiki. The tutorial assumes that the website subdomain, language code and database name<ref group="lower-alpha">(e.g.: <code><nowiki>https://en.prolewiki.org</nowiki></code>, <code>en</code>, <code>prole_en</code>)</ref> follow the same pattern. As an example, a non-existent "aa" language code will be used, but it should be changed to the language that is being included (e.g.: <code>en</code> for English, <code>fr</code> for French, <code>ru</code> for Russian, etc.). We can check the existing language on Wikipedia as a reference for its language code.
 
===Step 1: Create new A Record for the site===


=== Step 1: Create new A Record for the site ===
*Go to our Namecheap account and add new A Record for the site, using the same configuration as the others, changing only the language code.
*Go to our Namecheap account and add new A Record for the site, using the same configuration as the others, changing only the language code.


===Step 2: Add site domain to Apache vHost directive & reissue certificate===
=== Step 2: Add site domain to Apache vHost directive & reissue certificate ===
The new language subdomain must be explicitly added to Apache for Let's Encrypt to detect it and issue the certificate with the correct SANs.
The new language subdomain must be explicitly added to Apache for Let's Encrypt to detect it and issue the certificate with the correct SANs.
* Open <code>/etc/apache2/sites-enabled/prolewiki.conf</code> for editing. There are 3 places to add the new subdomain:
* Open <code>/etc/apache2/sites-enabled/prolewiki.conf</code> for editing. There are 3 places to add the new subdomain:
** The 1st and 2nd <code>ServerAlias</code> lines in the <code>VirtualHost</code> blocks for port :80 and :443.
** The 1st and 2nd <code>ServerAlias</code> lines in the <code>VirtualHost</code> blocks for port :80 and :443.
** The <code>RewriteCond</code> lines in approximately the middle of the file.
** The <code>RewriteCond</code> lines in approximately the middle of the file.
* Add entries for the new subdomain so that the placemet, formatting, etc, match the existing entries.
* Add entries for the new subdomain so that the placement, formatting, etc, match the existing entries.
* Run <code>apache -t</code> and look for anything worse than a <code>warn</code>, or anything likely to cause problems
* Run <code>apache2ctl -t</code> and look for anything worse than a <code>warn</code>, or anything likely to cause problems
* Run <code>certbot</code>
* Run <code>certbot</code>


===Step 3: Create new database for the site===
=== Step 3: Create new database for the site ===
<ul>
<ul>
<li> Open command <syntaxhighlight inline lang="bash">mysql</syntaxhighlight>
<li> Open command <syntaxhighlight inline lang="bash">mysql</syntaxhighlight>
Line 21: Line 20:
<li> Exit mysql by typing <syntaxhighlight inline lang="mysql">exit</syntaxhighlight>
<li> Exit mysql by typing <syntaxhighlight inline lang="mysql">exit</syntaxhighlight>
</ul>
</ul>
===Step 4: Add basic schema to database===


*Go to maintenance folder (<syntaxhighlight inline lang="bash">cd /var/www/prole/maintenance</syntaxhighlight>)
=== Step 4: Add basic schema to database ===
*Input the command <code>mysql prole_aa < /var/www/prole/maintenance/tables-generated.sql</code>
*Input the command <code>mysql prole_aa < /var/www/prolewiki/maintenance/tables-generated.sql</code>
After that, we probably have to add additional extension tables. Check the errors given and find clues for what extension is crashing and what tables they are using. Most extensions which require additional database tables will feature an <code>sql/</code> folder inside. You'll need to run
 
<code>mysql prole_aa < /var/www/prolewiki/extensions/[Extension]/sql/table_name_usually.sql</code>
 
so you can manually add those tables. (MediaWiki pls fix)


===Step 5: Add new site to site configuration===
Here is a list of extensions which we have to add those tables:
CreatedPagesList
Flow (extensions/Flow/sql/mysql/tables-generated.sql)


*Edit <code>/var/www/prole/LocalSettings.php</code>
=== Step 5: Add new site to server registry configuration ===
*Add the following lines where there are similar ones, and before the "language selector":
*Edit <code>/var/www/prolewiki/pw-conf/ServerRegistry.php</code>
*In our wiki, we use an array to define wiki codes. Just add the new language code to it
<syntaxhighlight lang="php">
<syntaxhighlight lang="php">
elseif (isset($_SERVER['SERVER_NAME']) && $_SERVER['SERVER_NAME'] == 'aa.prolewiki.org') {
$wikiCodes = ['shared','aa','de','el','en','es','fa','fr','pt','ru','zh'];
    $wikiId = 'aa';
</syntaxhighlight>We have to hard-code namespace localizations. We do that as a big switch-case in the server config file. Add these lines, making the necessary changes according to the necessity of the language (not all languages require to rename MetaNamespaces and Sitename for instance)<syntaxhighlight lang="php">
}
    case 'aa':
</syntaxhighlight>
$wgMatomoIDSite = "xx";
*Add this code block where there are similar ones like it, changing the options to the target language:
$wgMetaNamespace = "ProleWiki";
<syntaxhighlight lang="php">
$wgMetaNamespaceTalk = "ProleWiki talk"
elseif ($wikiId == 'aa') {
$wgSitename = "ProleWiki"
$wgServer = "https://aa.prolewiki.org";
$wgExtraNamespaces = [
$wgDBname = "prole_aa";
NS_TALK => 'Talk'
$wgLanguageCode = 'aa';
NS_LBRY => 'Library'
$wgLogo = "/resources/assets/prolewiki_logo_aa.png";
NS_LBRY_TALK => 'Library discussion'
$wgExtraNamespaces = [
NS_ESY => 'Essay'
NS_LBRY => 'Library',
NS_ESY_TALK => 'Essay critique'
NS_LBRY_TALK => 'Library_talk',
NS_PORTAL => 'Portal'
NS_ESY => 'Essay',
NS_PORTAL_TALK => 'Portal talk'
NS_ESY_TALK => 'Essay_talk',
NS_QUOTE => 'Quotes'
NS_USER => 'Comrade',
NS_QUOTE_TALK => 'Quotes talk'
NS_USER_TALK => 'Comradeship',
NS_USER => 'Comrade'
NS_QUOTE => 'Quotes',
NS_USER_TALK => 'Comradeship'
NS_QUOTE_TALK => 'Quotes_talk'
];
];
break; // don't forget break; in switch case
$wgMatomoIDSite = "X"; // Change to Matomo site
$wgMetaNamespace = "ProleWiki"; // Only necessary for wikis which use a different alphabet
$wgSitename = "ProleWiki"; // Same as above
$wgNamespaceAliases['ProleWiki'] = NS_PROJECT; // Same as above, leaving this as it is as a Latin alphabet fallback for the ProleWiki: namespace
$wgWikiSeoDefaultImage = '/resources/assets/seo/seo_aa.png';
$wgPageImagesOpenGraphFallbackImage = "/resources/assets/seo/seo_aa.png";
// Wikibase
wfLoadExtension( 'WikibaseClient', "$IP/extensions/Wikibase/extension-client.json" );
require_once "$IP/extensions/Wikibase/client/ExampleSettings.php";
$wgWBClientSettings['siteGlobalID'] = 'aa';
}
</syntaxhighlight>
*Save the file
===Step 6: Add site to sites table in database and update it===
*Go to <code>/var/www/prole/maintenance/</code>
*Input the following:
<syntaxhighlight lang="bash">
php addSite.php aa prolewiki --wiki shared --pagepath=https://aa.prolewiki.org/wiki/\$1  --filepath=https://aa.prolewiki.org/\$1 --language aa --interwiki-id aa
</syntaxhighlight>
*This should be done for all wikis. To do that, you should use:
<syntaxhighlight lang="bash">
php exportSites.php --wiki shared sites.xml
</syntaxhighlight>
*Then you import it for every wiki using (where wiki-id is <code>de</code>, <code>en</code>, <code>es</code>, <code>fr</code>, <code>pt</code>, <code>ru</code>, <code>aa</code>, etc.):
<syntaxhighlight lang="bash">
php importSites.php --wiki <wiki-id> sites.xml
</syntaxhighlight>
*Update all databases (where wiki-id includes <code>shared</code> as well:
<syntaxhighlight lang="bash">
php update.php --wiki <wiki-id> --quick
</syntaxhighlight>
</syntaxhighlight>
=== Step 6: Add site to sites table in shared database and update all databases ===
==== With script ====
*Go to the root directory <code>/var/www/prolewiki</code>
*[[Comrade:Forte|Forte]] created several scripts on <code>pw-conf/scripts/</code> folder. You can simply add the language code to the array declared in the file named <code>wikicodes.sh</code>:
<code>wikis=("en" "pt" "es" "de" "fr" "ru" "zh" "el" "fa" "aa")</code>
The sites are listed on the order of addition, just add to the end of the array. Then, from the root directory, run the script with:
<code>pw-conf/scripts/./site_refresh.sh</code>
==== Manually ====
You can still add manually a new site, by running from the root folder (<code>/var/www/prolewiki/</code>):
<code>php maintenance/run.php ./maintenance/addSite.php aa prolewiki --wiki shared --pagepath=<nowiki>https://aa.prolewiki.org/wiki/\$1</nowiki>  --filepath=<nowiki>https://aa.prolewiki.org/\$1</nowiki> --language aa --interwiki-id aa</code>
=== Notes ===
<references group="lower-alpha"/>

Latest revision as of 14:58, 21 April 2024

The following is a step-by-step tutorial on how to add new languages to ProleWiki. The tutorial assumes that the website subdomain, language code and database name[a] follow the same pattern. As an example, a non-existent "aa" language code will be used, but it should be changed to the language that is being included (e.g.: en for English, fr for French, ru for Russian, etc.). We can check the existing language on Wikipedia as a reference for its language code.

Step 1: Create new A Record for the site

  • Go to our Namecheap account and add new A Record for the site, using the same configuration as the others, changing only the language code.

Step 2: Add site domain to Apache vHost directive & reissue certificate

The new language subdomain must be explicitly added to Apache for Let's Encrypt to detect it and issue the certificate with the correct SANs.

  • Open /etc/apache2/sites-enabled/prolewiki.conf for editing. There are 3 places to add the new subdomain:
    • The 1st and 2nd ServerAlias lines in the VirtualHost blocks for port :80 and :443.
    • The RewriteCond lines in approximately the middle of the file.
  • Add entries for the new subdomain so that the placement, formatting, etc, match the existing entries.
  • Run apache2ctl -t and look for anything worse than a warn, or anything likely to cause problems
  • Run certbot

Step 3: Create new database for the site

  • Open command mysql
  • Type in CREATE DATABASE prole_aa;
  • Give permission to database user by typing GRANT ALL PRIVILEGES ON prole_aa.* TO 'proledbuser'@'localhost';
  • Exit mysql by typing exit

Step 4: Add basic schema to database

  • Input the command mysql prole_aa < /var/www/prolewiki/maintenance/tables-generated.sql

After that, we probably have to add additional extension tables. Check the errors given and find clues for what extension is crashing and what tables they are using. Most extensions which require additional database tables will feature an sql/ folder inside. You'll need to run

mysql prole_aa < /var/www/prolewiki/extensions/[Extension]/sql/table_name_usually.sql

so you can manually add those tables. (MediaWiki pls fix)

Here is a list of extensions which we have to add those tables:

CreatedPagesList
Flow (extensions/Flow/sql/mysql/tables-generated.sql)

Step 5: Add new site to server registry configuration

  • Edit /var/www/prolewiki/pw-conf/ServerRegistry.php
  • In our wiki, we use an array to define wiki codes. Just add the new language code to it
$wikiCodes = ['shared','aa','de','el','en','es','fa','fr','pt','ru','zh'];

We have to hard-code namespace localizations. We do that as a big switch-case in the server config file. Add these lines, making the necessary changes according to the necessity of the language (not all languages require to rename MetaNamespaces and Sitename for instance)

    case 'aa':
		$wgMatomoIDSite = "xx";
		$wgMetaNamespace = "ProleWiki";
		$wgMetaNamespaceTalk = "ProleWiki talk"
		$wgSitename = "ProleWiki"
		$wgExtraNamespaces = [
			NS_TALK => 'Talk'
			NS_LBRY => 'Library'
			NS_LBRY_TALK => 'Library discussion'
			NS_ESY => 'Essay'
			NS_ESY_TALK => 'Essay critique'
			NS_PORTAL => 'Portal'
			NS_PORTAL_TALK => 'Portal talk'
			NS_QUOTE => 'Quotes'
			NS_QUOTE_TALK => 'Quotes talk'
			NS_USER => 'Comrade'
			NS_USER_TALK => 'Comradeship'
		];
		break;  // don't forget break; in switch case

Step 6: Add site to sites table in shared database and update all databases

With script

  • Go to the root directory /var/www/prolewiki
  • Forte created several scripts on pw-conf/scripts/ folder. You can simply add the language code to the array declared in the file named wikicodes.sh:

wikis=("en" "pt" "es" "de" "fr" "ru" "zh" "el" "fa" "aa")

The sites are listed on the order of addition, just add to the end of the array. Then, from the root directory, run the script with:

pw-conf/scripts/./site_refresh.sh

Manually

You can still add manually a new site, by running from the root folder (/var/www/prolewiki/):

php maintenance/run.php ./maintenance/addSite.php aa prolewiki --wiki shared --pagepath=https://aa.prolewiki.org/wiki/\$1  --filepath=https://aa.prolewiki.org/\$1 --language aa --interwiki-id aa

Notes

  1. (e.g.: https://en.prolewiki.org, en, prole_en)