// Value is provided by user, the name shown is localized for the user.
$options[$params['all']] = wfMessage( 'namespacesall' )->text();
}
- // Add all namespaces as options (in the content language)
- $options +=
- MediaWikiServices::getInstance()->getContentLanguage()->getFormattedNamespaces();
+ if ( $params['in-user-lang'] ?? false ) {
+ global $wgLang;
+ $lang = $wgLang;
+ } else {
+ $lang = MediaWikiServices::getInstance()->getContentLanguage();
+ }
+ // Add all namespaces as options
+ $options += $lang->getFormattedNamespaces();
$optionsOut = [];
// Filter out namespaces below 0 and massage labels
// main we don't use "" but the user message describing it (e.g. "(Main)" or "(Article)")
$nsName = wfMessage( 'blanknamespace' )->text();
} elseif ( is_int( $nsId ) ) {
- $nsName = MediaWikiServices::getInstance()->getContentLanguage()->
- convertNamespace( $nsId );
+ $nsName = $lang->convertNamespace( $nsId );
}
$optionsOut[$nsId] = $nsName;
}
''
) . "\u{00A0}" .
Html::namespaceSelector(
- [ 'selected' => $this->opts['namespace'], 'all' => '' ],
+ [ 'selected' => $this->opts['namespace'], 'all' => '', 'in-user-lang' => true ],
[
'name' => 'namespace',
'id' => 'namespace',
'selected' => ( $isSameSourceAsBefore ?
$this->namespace :
( $defaultNamespace || '' ) ),
+ 'in-user-lang' => true,
], [
'name' => "namespace",
// mw-import-namespace-interwiki, mw-import-namespace-upload
*/
protected function namespaceFilterForm( FormOptions $opts ) {
$nsSelect = Html::namespaceSelector(
- [ 'selected' => $opts['namespace'], 'all' => '' ],
+ [ 'selected' => $opts['namespace'], 'all' => '', 'in-user-lang' => true ],
[ 'name' => 'namespace', 'id' => 'namespace' ]
);
$nsLabel = Xml::label( $this->msg( 'namespace' )->text(), 'namespace' );
[
'selected' => $opts['namespace'],
'all' => '',
- 'label' => $this->msg( 'namespace' )->text()
+ 'label' => $this->msg( 'namespace' )->text(),
+ 'in-user-lang' => true,
], [
'name' => 'namespace',
'id' => 'namespace',
[
'selected' => $namespace,
'all' => '',
- 'label' => $this->msg( 'namespace' )->text()
+ 'label' => $this->msg( 'namespace' )->text(),
+ 'in-user-lang' => true,
], [
'name' => 'namespace',
'id' => 'namespace',
protected function powerSearchBox( $term, array $opts ) {
$rows = [];
$activeNamespaces = $this->specialSearch->getNamespaces();
- $langConverter = MediaWikiServices::getInstance()->getContentLanguage()->getConverter();
+ $langConverter = $this->specialSearch->getLanguage();
foreach ( $this->searchConfig->searchableNamespaces() as $namespace => $name ) {
$subject = MWNamespace::getSubject( $namespace );
if ( !isset( $rows[$subject] ) ) {
),
'Basic namespace selector with a custom label but no id attribtue for the <select>'
);
+
+ $this->assertEquals(
+ '<select id="namespace" name="namespace">' . "\n" .
+ '<option value="0">(Principal)</option>' . "\n" .
+ '<option value="1">Discusión</option>' . "\n" .
+ '<option value="2">Usuario</option>' . "\n" .
+ '<option value="3">Usuario discusión</option>' . "\n" .
+ '<option value="4">Wiki</option>' . "\n" .
+ '<option value="5">Wiki discusión</option>' . "\n" .
+ '<option value="6">Archivo</option>' . "\n" .
+ '<option value="7">Archivo discusión</option>' . "\n" .
+ '<option value="8">MediaWiki</option>' . "\n" .
+ '<option value="9">MediaWiki discusión</option>' . "\n" .
+ '<option value="10">Plantilla</option>' . "\n" .
+ '<option value="11">Plantilla discusión</option>' . "\n" .
+ '<option value="12">Ayuda</option>' . "\n" .
+ '<option value="13">Ayuda discusión</option>' . "\n" .
+ '<option value="14">Categoría</option>' . "\n" .
+ '<option value="15">Categoría discusión</option>' . "\n" .
+ '<option value="100">Personalizado</option>' . "\n" .
+ '<option value="101">Personalizado discusión</option>' . "\n" .
+ '</select>',
+ Html::namespaceSelector(
+ [ 'in-user-lang' => true ]
+ ),
+ 'Basic namespace selector in user language'
+ );
}
/**