IntuitionTextdomains.php

Go to the documentation of this file.
00001 <?php
00016 class PremadeIntuitionTextdomains extends PremadeMediawikiExtensionGroups {
00017     protected $useConfigure = false;
00018     protected $groups;
00019     protected $idPrefix = 'tsint-';
00020     protected $namespace = NS_INTUITION;
00021 
00022     protected function processGroups( $groups ) {
00023         $fixedGroups = array();
00024         foreach ( $groups as $g ) {
00025             if ( !is_array( $g ) ) {
00026                 $g = array( $g );
00027             }
00028 
00029             $name = $g['name'];
00030             $sanitizedName = preg_replace( '/\s+/', '', strtolower( $name ) );
00031 
00032             if ( isset( $g['id'] ) ) {
00033                 $id = $g['id'];
00034             } else {
00035                 $id = $this->idPrefix . $sanitizedName;
00036             }
00037 
00038             if ( isset( $g['file'] ) ) {
00039                 $file = $g['file'];
00040             } else {
00041                 // Intuition text-domains are case-insensitive and internally
00042                 // converts to lowercase names starting with a capital letter.
00043                 // eg. "MyTool" -> "Mytool.i18n.php"
00044                 // No subdirectories!
00045                 $file = ucfirst( $sanitizedName ) . '.i18n.php';
00046             }
00047 
00048             if ( isset( $g['descmsg'] ) ) {
00049                 $descmsg = $g['descmsg'];
00050             } else {
00051                 $descmsg = "$id-desc";
00052             }
00053 
00054             if ( isset( $g['url'] ) ) {
00055                 $url = $g['url'];
00056             } else {
00057                 $url = false;
00058             }
00059 
00060             $newgroup = array(
00061                 'name' => 'Intuition - ' . $name,
00062                 'file' => $file,
00063                 'descmsg' => $descmsg,
00064                 'url' => $url,
00065             );
00066 
00067             // Prefix is required, if not customized use the sanitized name
00068             if ( !isset( $g['prefix'] ) ) {
00069                 $g['prefix'] = "$sanitizedName-";
00070             }
00071 
00072             // All messages are prefixed with their groupname
00073             $g['mangle'] = array( '*' );
00074 
00075             // Prevent E_NOTICE undefined index.
00076             // PremadeMediawikiExtensionGroups::factory should probably check this better instead
00077             if ( !isset( $g['ignored'] ) ) {
00078                 $g['ignored'] = array();
00079             }
00080 
00081             if ( !isset( $g['optional'] ) ) {
00082                 $g['optional'] = array();
00083             }
00084 
00085             $copyvars = array(
00086                 'ignored',
00087                 'optional',
00088                 'var',
00089                 'desc',
00090                 'prefix',
00091                 'mangle',
00092                 'magicfile',
00093                 'aliasfile'
00094             );
00095 
00096             foreach ( $copyvars as $var ) {
00097                 if ( isset( $g[$var] ) ) {
00098                     $newgroup[$var] = $g[$var];
00099                 }
00100             }
00101 
00102             $fixedGroups[$id] = $newgroup;
00103         }
00104 
00105         return $fixedGroups;
00106     }
00107 }
Generated on Tue Oct 29 00:00:23 2013 for MediaWiki Translate Extension by  doxygen 1.6.3