Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
PremadeIntuitionTextdomains.php
Go to the documentation of this file.
1<?php
17 protected $groups;
18 protected $idPrefix = 'tsint-';
19
20 protected function getDefaultNamespace() {
21 return NS_INTUITION;
22 }
23
24 protected function processGroups( $groups ) {
25 $fixedGroups = [];
26 foreach ( $groups as $g ) {
27 $name = $g['name'];
28 $sanitizedName = preg_replace( '/\s+/', '', strtolower( $name ) );
29
30 $id = $g['id'] ?? $this->idPrefix . $sanitizedName;
31
32 // Canonical names for Intuition text-domains are lowercase
33 // eg. "MyTool" -> "mytool/en.json"
34 $file = $g['file'] ?? "$sanitizedName/%CODE%.json";
35
36 $descmsg = $g['descmsg'] ?? "$id-desc";
37
38 $newgroup = [
39 'name' => 'Intuition - ' . $name,
40 'file' => $file,
41 'descmsg' => $descmsg,
42 ];
43
44 // Prefix is required, if not customized use the sanitized name
45 if ( !isset( $g['prefix'] ) ) {
46 $g['prefix'] = "$sanitizedName-";
47 }
48
49 // All messages are prefixed with their groupname
50 $g['mangle'] = [ '*' ];
51
52 // Prevent E_NOTICE undefined index.
53 // PremadeMediawikiExtensionGroups::factory should probably check this better instead
54 if ( !isset( $g['ignored'] ) ) {
55 $g['ignored'] = [];
56 }
57
58 if ( !isset( $g['optional'] ) ) {
59 $g['optional'] = [];
60 }
61
62 $g['format'] = 'json';
63
64 $copyvars = [
65 'aliasfile',
66 'desc',
67 'format',
68 'ignored',
69 'magicfile',
70 'mangle',
71 'optional',
72 'prefix',
73 'var',
74 ];
75
76 foreach ( $copyvars as $var ) {
77 if ( isset( $g[$var] ) ) {
78 $newgroup[$var] = $g[$var];
79 }
80 }
81
82 $fixedGroups[$id] = $newgroup;
83 }
84
85 return $fixedGroups;
86 }
87}
Support for tools using Intuition at the Toolserver and Wikimedia Labs.
getDefaultNamespace()
Get the default namespace.
Class which handles special definition format for MediaWiki extensions and skins.