Manual:$wgLanguageCode

From MediaWiki.org

Jump to: navigation, search
Localization: $wgLanguageCode
Site language code.
Introduced in version: pre 1.1.0
Removed in version: still in use
Allowed values: (string)
Default value: 'en'

Other settings: Alphabetical | By Function


Contents

[edit] Details

Site language code. Should be one of the ./languages/messages/Messages(.*).php files.

This specifies which language your page content is in, and also provides the default language for your wiki's interface. While users can switch the language of interface messages in their preferences, anonymous visitors will see the wiki's interface in the content language, i.e. the one specified by $wgLanguageCode.

Note Note: In MediaWiki 1.8 or older, if you change this after installation, you should run the maintenance/rebuildMessages.php script to rebuild the user interface messages (MediaWiki namespace). Otherwise, you will not see the interface in the new language, or a mix of the old and new languages. Note that running that script will override any custom interface messages you may have created.

[edit] Hints

In 1.6.8: the string is case sensitive. The installer installs though small (for example "de"). This results into only a partial use of the language file. This is fixed if you use "De", which then uses the LanguageDe.php correctly.

[edit] Change existing users' language settings

You can change existing users' language settings with the userOptions.php maintenance script. They will still be able to change their settings back unless you disable that option (see below).

php userOptions.php language --old en --new cs

[edit] Disable user selection of language

If you want to have your wiki in a certain language and not allow users to change this setting, there is a new variable in 1.16, otherwise you'll have to use a hack and comment out some code.

MediaWiki version: trunk (1.16)

If you are using the development version, you can use the new $wgHiddenPrefs in LocalSettings.php:

// disable language selection
$wgHiddenPrefs[] = 'language';
// if you want to disable variants as well
$wgHiddenPrefs[] = 'variant';
$wgHiddenPrefs[] = 'noconvertlink';
MediaWiki version: 1.15 and lower
  1. Open languages/Names.php and delete all the languages from the array that you want to disable, leaving only your default language. The result will be a selector (on the Special:preferences page) with only the one language to select from, so in fact it is fixed.
  2. In includes/specials/SpecialPreferences.php comment out the following code (and do not forget the second comment opening after ... to choose from*/ which is closing your first comment prematurely):
/*
		list( $lsLabel, $lsSelect) = Xml::languageSelector( $this->mUserLanguage );
		$wgOut->addHTML(
			$this->tableRow( $lsLabel, $lsSelect )
		);

		/* see if there are multiple language variants to choose from*/
/*		if(!$wgDisableLangConversion) {
			$variants = $wgContLang->getVariants();
			$variantArray = array();

			$languages = Language::getLanguageNames( true );

			foreach($variants as $v) {
				$v = str_replace( '_', '-', strtolower($v));
				if( array_key_exists( $v, $languages ) ) {
					// If it doesn't have a name, we'll pretend it doesn't exist
					$variantArray[$v] = $languages[$v];
				}
			}

			$options = "\n";
			foreach( $variantArray as $code => $name ) {
				$selected = ($code == $this->mUserVariant);
				$options .= Xml::option( "$code - $name", $code, $selected ) . "\n";
			}

			if(count($variantArray) > 1) {
				$wgOut->addHtml(
					$this->tableRow(
						Xml::label( wfMsg( 'yourvariant' ), 'wpUserVariant' ),
						Xml::tags( 'select',
							array( 'name' => 'wpUserVariant', 'id' => 'wpUserVariant' ),
							$options
						)
					)
				);
			}
		}
*/