MediaWiki  1.23.2
Language Class Reference

Internationalisation code. More...

Inheritance diagram for Language:

Public Member Functions

 __construct ()
 
 __destruct ()
 Reduce memory usage. More...
 
 addMagicWordsByLang ( $newWords)
 Add magic words to the extension array. More...
 
 alignEnd ()
 Return 'right' or 'left' as appropriate alignment for line-end for this language's text direction. More...
 
 alignStart ()
 Return 'left' or 'right' as appropriate alignment for line-start for this language's text direction. More...
 
 armourMath ( $text)
 Put custom tags (e.g. More...
 
 autoConvertToAllVariants ( $text)
 convert text to all supported variants More...
 
 capitalizeAllNouns ()
 
 caseFold ( $s)
 Return a case-folded representation of $s. More...
 
 checkTitleEncoding ( $s)
 
 commafy ( $number)
 Adds commas to a given number. More...
 
 commaList (array $list)
 Take a list of strings and build a locale-friendly comma-separated list, using the local comma-separator message. More...
 
 convert ( $text)
 convert text to different variants of a language. More...
 
 convertCategoryKey ( $key)
 
 convertForSearchResult ( $termsArray)
 
 convertGrammar ( $word, $case)
 Grammatical transformations, needed for inflected languages Invoked by putting {{grammar:case|word}} in a message. More...
 
 convertHtml ( $text, $isTitle=false)
 Perform output conversion on a string, and encode for safe HTML output. More...
 
 convertNamespace ( $ns)
 Convert a namespace index to a string in the preferred variant. More...
 
 convertPlural ( $count, $forms)
 Plural form transformations, needed for some languages. More...
 
 convertTitle ( $title)
 Convert a Title object to a string in the preferred variant. More...
 
 date ( $ts, $adj=false, $format=true, $timecorrection=false)
 
 dateFormat ( $usePrefs=true)
 This is meant to be used by time(), date(), and timeanddate() to get the date preference they're supposed to use, it should be used in all children. More...
 
 digitGroupingPattern ()
 
 digitTransformTable ()
 
 emphasize ( $text)
 Italic is unsuitable for some languages. More...
 
 fallback8bitEncoding ()
 
 findVariantLink (&$link, &$nt, $ignoreOtherCond=false)
 If a language supports multiple variants, it is possible that non-existing link in one variant actually exists in another variant. More...
 
 firstChar ( $s)
 Get the first character of a string. More...
 
 fixVariableInNamespace ( $talk)
 
 formatBitrate ( $bps)
 Format a bitrate for output, using an appropriate unit (bps, kbps, Mbps, Gbps, Tbps, Pbps, Ebps, Zbps or Ybps) according to the magnitude in question. More...
 
 formatComputingNumbers ( $size, $boundary, $messageKey)
 
 formatDuration ( $seconds, array $chosenIntervals=array())
 Takes a number of seconds and turns it into a text using values such as hours and minutes. More...
 
 formatExpiry ( $expiry, $format=true)
 Decode an expiry (block, protection, etc) which has come from the DB. More...
 
 formatNum ( $number, $nocommafy=false)
 Normally we output all numbers in plain en_US style, that is 293,291.235 for twohundredninetythreethousand-twohundredninetyone point twohundredthirtyfive. More...
 
 formatNumNoSeparators ( $number)
 Front-end for non-commafied formatNum. More...
 
 formatSize ( $size)
 Format a size in bytes for output, using an appropriate unit (B, KB, MB, GB, TB, PB, EB, ZB or YB) according to the magnitude in question. More...
 
 formatTimePeriod ( $seconds, $format=array())
 
 gender ( $gender, $forms)
 Provides an alternative text depending on specified gender. More...
 
 getAllMessages ()
 
 getArrow ( $direction='forwards')
 An arrow, depending on the language direction. More...
 
 getBookstoreList ()
 Exports $wgBookstoreListEn. More...
 
 getCode ()
 Get the RFC 3066 code for this language object. More...
 
 getCompiledPluralRules ()
 Get the compiled plural rules for the language. More...
 
 getConverter ()
 Return the LanguageConverter used in the Language. More...
 
 getConvRuleTitle ()
 Get the conversion rule title, if any. More...
 
 getDateFormats ()
 
 getDateFormatString ( $type, $pref)
 Get a format string for a given type and preference. More...
 
 getDatePreferenceMigrationMap ()
 
 getDatePreferences ()
 
 getDefaultDateFormat ()
 
 getDefaultVariant ()
 
 getDir ()
 Return the correct HTML 'dir' attribute value for this language. More...
 
 getDirMark ( $opposite=false)
 A hidden direction mark (LRM or RLM), depending on the language direction. More...
 
 getDirMarkEntity ( $opposite=false)
 A hidden direction mark (LRM or RLM), depending on the language direction. More...
 
 getDurationIntervals ( $seconds, array $chosenIntervals=array())
 Takes a number of seconds and returns an array with a set of corresponding intervals. More...
 
 getExtraHashOptions ()
 returns language specific options used by User::getPageRenderHash() for example, the preferred language variant More...
 
 getExtraUserToggles ()
 
 getFallbackLanguageCode ()
 Same as getFallbacksFor for current language. More...
 
 getFallbackLanguages ()
 
 getFormattedNamespaces ()
 A convenience function that returns the same thing as getNamespaces() except with the array values changed to ' ' where it found '_', useful for producing output to be displayed e.g. More...
 
 getFormattedNsText ( $index)
 A convenience function that returns the same thing as getNsText() except with '_' changed to ' ', useful for producing output. More...
 
 getGenderNsText ( $index, $gender)
 Returns gender-dependent namespace alias if available. More...
 
 getGrammarForms ()
 Get the grammar forms for the content language. More...
 
 getHebrewCalendarMonthName ( $key)
 
 getHebrewCalendarMonthNameGen ( $key)
 
 getHijriCalendarMonthName ( $key)
 
 getHtmlCode ()
 Get the code in Bcp47 format which we can use inside of html lang="" tags. More...
 
 getHumanTimestamp (MWTimestamp $ts, MWTimestamp $relativeTo, User $user)
 Convert an MWTimestamp into a pretty human-readable timestamp using the given user preferences and relative base time. More...
 
 getImageFile ( $image)
 
 getIranianCalendarMonthName ( $key)
 
 getLangObj ()
 
 getLanguageName ( $code)
 Get the native language name of $code. More...
 
 getLocalNsIndex ( $text)
 Get a namespace key by value, case insensitive. More...
 
 getMagic ( $mw)
 Fill a MagicWord object with data from here. More...
 
 getMagicWords ()
 Get all magic words from cache. More...
 
 getMessage ( $key)
 
 getMessageFromDB ( $msg)
 Get a message from the MediaWiki namespace. More...
 
 getMonthAbbreviation ( $key)
 
 getMonthAbbreviationsArray ()
 
 getMonthName ( $key)
 
 getMonthNameGen ( $key)
 
 getMonthNamesArray ()
 
 getNamespaceAliases ()
 
 getNamespaceIds ()
 
 getNamespaces ()
 Returns an array of localised namespaces indexed by their numbers. More...
 
 getNsIndex ( $text)
 Get a namespace key by value, case insensitive. More...
 
 getNsText ( $index)
 Get a namespace value by key $mw_ns = $wgContLang->getNsText( NS_MEDIAWIKI ); echo $mw_ns; // prints 'MediaWiki' More...
 
 getParentLanguage ()
 Get the "parent" language which has a converter to convert a "compatible" language (in another variant) to this language (eg. More...
 
 getParsedTitle ()
 For languages that support multiple variants, the title of an article may be displayed differently in different variants. More...
 
 getPluralRuleIndexNumber ( $number)
 Find the index number of the plural rule appropriate for the given number. More...
 
 getPluralRules ()
 Get the plural rules for the language. More...
 
 getPluralRuleType ( $number)
 Find the plural rule type appropriate for the given number For example, if the language is set to Arabic, getPluralType(5) should return 'few'. More...
 
 getPluralRuleTypes ()
 Get the plural rule types for the language. More...
 
 getPreferredVariant ()
 
 getSpecialPageAliases ()
 Get special page names, as an associative array case folded alias => real name. More...
 
 getURLVariant ()
 
 getUserToggle ( $tog)
 
 getVariantname ( $code, $usemsg=true)
 short names for language variants used for language conversion links. More...
 
 getVariants ()
 Get the list of variants supported by this language see sample implementation in LanguageZh.php. More...
 
 getWeekdayAbbreviation ( $key)
 
 getWeekdayName ( $key)
 
 hasVariant ( $variant)
 Check if the language has the specific variant. More...
 
 hasVariants ()
 Check if this is a language with variants. More...
 
 hasWordBreaks ()
 Most writing systems use whitespace to break up words. More...
 
 iconv ( $in, $out, $string)
 
 initContLang ()
 Hook which will be called if this is the content language. More...
 
 initEncoding ()
 
 isMultibyte ( $str)
 
 isRTL ()
 For right-to-left language support. More...
 
 lc ( $str, $first=false)
 
 lcCallback ( $matches)
 
 lcfirst ( $str)
 
 linkPrefixCharset ()
 A regular expression character set to match legal word-prefixing characters which should be merged onto a link of the form foo[[bar]]. More...
 
 linkPrefixExtension ()
 To allow "foo[[bar]]" to extend the link over the whole word "foobar". More...
 
 linkTrail ()
 A regular expression to match legal word-trailing characters which should be merged onto a link of the form [[foo]]bar. More...
 
 listToText (array $l)
 Take a list of strings and build a locale-friendly comma-separated list, using the local comma-separator message. More...
 
 markNoConversion ( $text, $noParse=false)
 Prepare external link text for conversion. More...
 
 needsGenderDistinction ()
 Whether this language uses gender-dependent namespace aliases. More...
 
 normalize ( $s)
 Convert a UTF-8 string to normal form C. More...
 
 normalizeForSearch ( $string)
 Some languages have special punctuation need to be normalized. More...
 
 parseFormattedNumber ( $number)
 
 pipeList (array $list)
 Same as commaList, but separate it with the pipe instead. More...
 
 recodeForEdit ( $s)
 
 recodeInput ( $s)
 
 replaceGrammarInNamespace ( $m)
 
 resetNamespaces ()
 Resets all of the namespace caches. More...
 
 segmentByWord ( $string)
 Some languages such as Chinese require word segmentation, Specify such segmentation when overridden in derived class. More...
 
 segmentForDiff ( $text)
 languages like Chinese need to be segmented in order for the diff to be of any use More...
 
 semicolonList (array $list)
 Take a list of strings and build a locale-friendly semicolon-separated list, using the local semicolon-separator message. More...
 
 separatorTransformTable ()
 
 setCode ( $code)
 
 setNamespaces (array $namespaces)
 Arbitrarily set all of the namespace names at once. More...
 
 specialList ( $page, $details, $oppositedm=true)
 Make a list item, used by various special pages. More...
 
 specialPage ( $name)
 
 sprintfDate ( $format, $ts, DateTimeZone $zone=null)
 This is a workalike of PHP's date() function, but with better internationalisation, a reduced set of format characters, and a better escaping format. More...
 
 time ( $ts, $adj=false, $format=true, $timecorrection=false)
 
 timeanddate ( $ts, $adj=false, $format=true, $timecorrection=false)
 
 transformUsingPairFile ( $file, $string)
 Transform a string using serialized data stored in the given file (which must be in the serialized subdirectory of $IP). More...
 
 translateBlockExpiry ( $str)
 
 truncate ( $string, $length, $ellipsis='...', $adjustLength=true)
 Truncate a string to a specified length in bytes, appending an optional string (e.g. More...
 
 truncateHtml ( $text, $length, $ellipsis='...')
 Truncate a string of valid HTML to a specified length in bytes, appending an optional string (e.g. More...
 
 uc ( $str, $first=false)
 Convert a string to uppercase. More...
 
 ucCallback ( $matches)
 
 ucfirst ( $str)
 Make a string's first character uppercase. More...
 
 ucwordbreaks ( $str)
 capitalize words at word breaks More...
 
 ucwordbreaksCallbackAscii ( $matches)
 
 ucwordbreaksCallbackMB ( $matches)
 
 ucwords ( $str)
 
 ucwordsCallbackMB ( $matches)
 
 ucwordsCallbackWiki ( $matches)
 
 unsegmentForDiff ( $text)
 and unsegment to show the result More...
 
 userAdjust ( $ts, $tz=false)
 Used by date() and time() to adjust the time output. More...
 
 userDate ( $ts, User $user, array $options=array())
 Get the formatted date for the given timestamp and formatted for the given user. More...
 
 userTime ( $ts, User $user, array $options=array())
 Get the formatted time for the given timestamp and formatted for the given user. More...
 
 userTimeAndDate ( $ts, User $user, array $options=array())
 Get the formatted date and time for the given timestamp and formatted for the given user. More...
 
 viewPrevNext (Title $title, $offset, $limit, array $query=array(), $atend=false)
 Generate (prev x| next x) (20|50|100...) type links for paging. More...
 

Static Public Member Functions

static classFromCode ( $code)
 
static factory ( $code)
 Get a cached or new language object for a given language code. More...
 
static fetchLanguageName ( $code, $inLanguage=null, $include='all')
 
static fetchLanguageNames ( $inLanguage=null, $include='mw')
 Get an array of language names, indexed by code. More...
 
static getCaseMaps ()
 
static getClassFileName ( $code)
 
static getCodeFromFileName ( $filename, $prefix='Language', $suffix='.php')
 Get the language code from a file name. More...
 
static getFallbackFor ( $code)
 Get the first fallback for a given language. More...
 
static getFallbacksFor ( $code)
 Get the ordered list of fallback languages. More...
 
static getFallbacksIncludingSiteLanguage ( $code)
 Get the ordered list of fallback languages, ending with the fallback language chain for the site language. More...
 
static getFileName ( $prefix='Language', $code, $suffix='.php')
 Get the name of a file for a certain language code. More...
 
static getJsonMessagesFileName ( $code)
 
static getLanguageNames ( $customisedOnly=false)
 Get native language names, indexed by code. More...
 
static getLocalisationCache ()
 Get the LocalisationCache instance. More...
 
static getMessageFor ( $key, $code)
 Get a message for a given language. More...
 
static getMessageKeysFor ( $code)
 Get all message keys for a given language. More...
 
static getMessagesFileName ( $code)
 
static getMessagesFor ( $code)
 Get all messages for a given language WARNING: this may take a long time. More...
 
static getTranslatedLanguageNames ( $code)
 Get translated language names. More...
 
static hebrewNumeral ( $num)
 Hebrew Gematria number formatting up to 9999. More...
 
static isKnownLanguageTag ( $tag)
 Returns true if a language code is an IETF tag known to MediaWiki. More...
 
static isSupportedLanguage ( $code)
 Checks whether any localisation is available for that language tag in MediaWiki (MessagesXx.php exists). More...
 
static isValidBuiltInCode ( $code)
 Returns true if a language code is of a valid form for the purposes of internal customisation of MediaWiki, via Messages*.php or *.json. More...
 
static isValidCode ( $code)
 Returns true if a language code string is of a valid form, whether or not it exists. More...
 
static isWellFormedLanguageTag ( $code, $lenient=false)
 Returns true if a language code string is a well-formed language tag according to RFC 5646. More...
 
static preloadLanguageClass ( $class)
 Includes language class files. More...
 
static romanNumeral ( $num)
 Roman number formatting up to 10000. More...
 

Public Attributes

 $dateFormatStrings = array()
 
 $mCode
 
LanguageConverter $mConverter
 
 $mExtendedSpecialPageAliases
 
 $mLoaded = false
 
 $mMagicExtensions = array()
 
 $mMagicHookDone = false
 
 $mNamespaceIds
 
 $mParentLanguage = false
 
 $mVariants
 
 $namespaceAliases
 
 $transformData = array()
 ReplacementArray object caches. More...
 

Static Public Attributes

static $dataCache
 
static $durationIntervals
 
static $mHebrewCalendarMonthGenMsgs
 
static $mHebrewCalendarMonthMsgs
 
static $mHijriCalendarMonthMsgs
 
static $mIranianCalendarMonthMsgs
 
static $mLangObjCache = array()
 
static $mMonthAbbrevMsgs
 
static $mMonthGenMsgs
 
static $mMonthMsgs
 
static $mWeekdayAbbrevMsgs
 
static $mWeekdayMsgs
 

Protected Member Functions

 doMagicHook ()
 Run the LanguageGetMagic hook once. More...
 
 handleExplicitPluralForms ( $count, array $forms)
 Handles explicit plural forms for Language::convertPlural() More...
 
 preConvertPlural ($forms, $count)
 Checks that convertPlural was given an array and pads it to requested amount of forms by copying the last one. More...
 
 removeBadCharFirst ( $string)
 Remove bytes that represent an incomplete Unicode character at the start of string (e.g. More...
 
 removeBadCharLast ( $string)
 Remove bytes that represent an incomplete Unicode character at the end of string (e.g. More...
 

Static Protected Member Functions

static convertDoubleWidth ( $string)
 convert double-width roman characters to single-width. More...
 
static insertSpace ( $string, $pattern)
 
static newFromCode ( $code)
 Create a language object for a given language code. More...
 

Protected Attributes

 $namespaceNames
 

Private Member Functions

 internalUserTimeAndDate ( $type, $ts, User $user, array $options)
 Internal helper function for userDate(), userTime() and userTimeAndDate() More...
 
 numLink (Title $title, $offset, $limit, array $query, $link, $tooltipMsg, $class)
 Helper function for viewPrevNext() that generates links. More...
 
 truncate_endBracket (&$tag, $tagType, $lastCh, &$openTags)
 truncateHtml() helper function (a) push or pop $tag from $openTags as needed (b) clear $tag value More...
 
 truncate_skip (&$ret, $text, $search, $start, $len=null)
 truncateHtml() helper function like strcspn() but adds the skipped chars to $ret More...
 

Static Private Member Functions

static hebrewYearStart ( $year)
 This calculates the Hebrew year start, as days since 1 September. More...
 
static tsToHebrew ( $ts)
 Converting Gregorian dates to Hebrew dates. More...
 
static tsToHijri ( $ts)
 Converting Gregorian dates to Hijri dates. More...
 
static tsToIranian ( $ts)
 Algorithm by Roozbeh Pournader and Mohammad Toossi to convert Gregorian dates to Iranian dates. More...
 
static tsToYear ( $ts, $cName)
 Algorithm to convert Gregorian dates to Thai solar dates, Minguo dates or Minguo dates. More...
 

Private Attributes

 $mHtmlCode = null
 

Static Private Attributes

static $fallbackLanguageCache = array()
 
static $GREG_DAYS = array( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 )
 
static $IRANIAN_DAYS = array( 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29 )
 

Detailed Description

Internationalisation code.

Definition at line 74 of file Language.php.

Constructor & Destructor Documentation

◆ __construct()

Language::__construct ( )

◆ __destruct()

Language::__destruct ( )

Reduce memory usage.

Definition at line 466 of file Language.php.

References $name, $value, and as.

Member Function Documentation

◆ addMagicWordsByLang()

Language::addMagicWordsByLang (   $newWords)

Add magic words to the extension array.

Parameters
$newWordsarray

Definition at line 3034 of file Language.php.

References $mMagicExtensions, as, and getFallbackLanguages().

◆ alignEnd()

Language::alignEnd ( )

Return 'right' or 'left' as appropriate alignment for line-end for this language's text direction.

Should be equivalent to CSS3 'end' text-align value....

Returns
String

Definition at line 2902 of file Language.php.

References isRTL().

◆ alignStart()

Language::alignStart ( )

Return 'left' or 'right' as appropriate alignment for line-start for this language's text direction.

Should be equivalent to CSS3 'start' text-align value....

Returns
String

Definition at line 2890 of file Language.php.

References isRTL().

◆ armourMath()

Language::armourMath (   $text)

Put custom tags (e.g.

-{ }-) around math to prevent conversion

Parameters
$textstring
Returns
string
Deprecated:
since 1.22 is no longer used

Definition at line 3842 of file Language.php.

◆ autoConvertToAllVariants()

Language::autoConvertToAllVariants (   $text)

convert text to all supported variants

Parameters
$textstring
Returns
array

Definition at line 3781 of file Language.php.

◆ capitalizeAllNouns()

Language::capitalizeAllNouns ( )
Returns
array

Definition at line 2946 of file Language.php.

◆ caseFold()

Language::caseFold (   $s)

Return a case-folded representation of $s.

This is a representation such that caseFold($s1)==caseFold($s2) if $s1 and $s2 are the same except for the case of their characters. It is not necessary for the value returned to make sense when displayed.

Do not perform any other normalisation in this function. If a caller uses this function when it should be using a more general normalisation function, then fix the caller.

Parameters
$sstring
Returns
string

Definition at line 2614 of file Language.php.

References $s, and uc().

◆ checkTitleEncoding()

Language::checkTitleEncoding (   $s)
Parameters
$sstring
Returns
string

Definition at line 2622 of file Language.php.

References $s, fallback8bitEncoding(), iconv(), and StringUtils\isUtf8().

◆ classFromCode()

static Language::classFromCode (   $code)
static
Parameters
$code
Returns
String Name of the language class

Definition at line 413 of file Language.php.

References ucfirst().

Referenced by newFromCode().

◆ commafy()

Language::commafy (   $number)

Adds commas to a given number.

Since
1.19
Parameters
$numbermixed
Returns
string

Reimplemented in LanguageKk_cyrl, LanguageKsh, LanguageRu, LanguageUk, LanguageHy, LanguageKaa, LanguageBe_tarask, LanguageBg, LanguageKu_ku, LanguageEt, LanguageKm, LanguageMy, LanguageEs, and LanguagePl.

Definition at line 3151 of file Language.php.

References $digitGroupingPattern, $matches, array(), and digitGroupingPattern().

Referenced by formatNum().

◆ commaList()

Language::commaList ( array  $list)

Take a list of strings and build a locale-friendly comma-separated list, using the local comma-separator message.

Parameters
$listarray of strings to put in a comma list
Returns
string

Definition at line 3259 of file Language.php.

References wfMessage().

◆ convert()

Language::convert (   $text)

convert text to different variants of a language.

Parameters
$textstring
Returns
string

Definition at line 3791 of file Language.php.

Referenced by convertHtml().

◆ convertCategoryKey()

Language::convertCategoryKey (   $key)
Parameters
$keystring
Returns
string

Definition at line 3861 of file Language.php.

◆ convertDoubleWidth()

static Language::convertDoubleWidth (   $string)
staticprotected

convert double-width roman characters to single-width.

range: ff00-ff5f ~= 0020-007f

Parameters
$stringstring
Returns
string

Definition at line 2682 of file Language.php.

Referenced by LanguageZh\convertForSearchResult(), LanguageYue\normalizeForSearch(), and normalizeForSearch().

◆ convertForSearchResult()

Language::convertForSearchResult (   $termsArray)
Parameters
$termsArrayarray
Returns
array

Reimplemented in LanguageZh.

Definition at line 2712 of file Language.php.

◆ convertGrammar()

Language::convertGrammar (   $word,
  $case 
)

Grammatical transformations, needed for inflected languages Invoked by putting {{grammar:case|word}} in a message.

Parameters
$wordstring
$casestring
Returns
string

Reimplemented in LanguageKk, LanguageKsh, LanguageOs, LanguageHe, LanguageLa, LanguageBs, LanguageKaa, LanguageRu, LanguageDsb, LanguageFi, LanguageHy, LanguageSl, LanguageTyv, LanguageCu, LanguageGa, LanguageHsb, LanguageUk, and LanguageHu.

Definition at line 3571 of file Language.php.

References getCode(), and global.

Referenced by replaceGrammarInNamespace().

◆ convertHtml()

Language::convertHtml (   $text,
  $isTitle = false 
)

Perform output conversion on a string, and encode for safe HTML output.

Parameters
$textString text to be converted
$isTitleBool whether this conversion is for the article title
Returns
string
Todo:
this should get integrated somewhere sane

Definition at line 3853 of file Language.php.

References convert().

◆ convertNamespace()

Language::convertNamespace (   $ns)

Convert a namespace index to a string in the preferred variant.

Parameters
$nsint
Returns
string

Definition at line 3811 of file Language.php.

◆ convertPlural()

Language::convertPlural (   $count,
  $forms 
)

Plural form transformations, needed for some languages.

For example, there are 3 form of plural in Russian and Polish, depending on "count mod 10". See [[w:Plural]] For English it is pretty simple.

Invoked by putting {{plural:count|wordform1|wordform2}} or {{plural:count|wordform1|wordform2|wordform3}}

Example: {{plural:{{NUMBEROFARTICLES}}|article|articles}}

Parameters
$countInteger: non-localized number
$formsArray: different plural forms
Returns
string Correct form of plural for $count in this language

Reimplemented in LanguageKsh.

Definition at line 3638 of file Language.php.

References $count, getPluralRuleIndexNumber(), and handleExplicitPluralForms().

◆ convertTitle()

Language::convertTitle (   $title)

Convert a Title object to a string in the preferred variant.

Parameters
$titleTitle
Returns
string

Definition at line 3801 of file Language.php.

References $title.

◆ date()

Language::date (   $ts,
  $adj = false,
  $format = true,
  $timecorrection = false 
)
Parameters
$tsMixed: the time format which needs to be turned into a date('YmdHis') format with wfTimestamp(TS_MW,$ts)
$adjBool: whether to adjust the time output according to the user configured offset ($timecorrection)
$formatMixed: true to use user's date format preference
$timecorrectionString|bool the time offset as returned by validateTimeZone() in Special:Preferences
Returns
string

Reimplemented in LanguageWa.

Definition at line 2045 of file Language.php.

References dateFormat(), getDateFormatString(), sprintfDate(), TS_MW, userAdjust(), and wfTimestamp().

Referenced by LanguageFi\translateBlockExpiry(), and userAdjust().

◆ dateFormat()

Language::dateFormat (   $usePrefs = true)

This is meant to be used by time(), date(), and timeanddate() to get the date preference they're supposed to use, it should be used in all children.

function timeanddate([...], $format = true) { $datePreference = $this->dateFormat($format); [...] }

Parameters
$usePrefsMixed: if true, the user's preference is used if false, the site/language default is used if int/string, assumed to be a format.
Returns
string

Definition at line 1983 of file Language.php.

References $wgUser, User\getDefaultOption(), and global.

Referenced by LanguageWa\date(), date(), internalUserTimeAndDate(), time(), LanguageWa\timeanddate(), and timeanddate().

◆ digitGroupingPattern()

Language::digitGroupingPattern ( )
Returns
String

Definition at line 3203 of file Language.php.

Referenced by commafy().

◆ digitTransformTable()

Language::digitTransformTable ( )
Returns
array

Definition at line 3210 of file Language.php.

Referenced by formatNum(), and parseFormattedNumber().

◆ doMagicHook()

Language::doMagicHook ( )
protected

Run the LanguageGetMagic hook once.

Definition at line 2993 of file Language.php.

References array(), getCode(), wfProfileIn(), wfProfileOut(), and wfRunHooks().

Referenced by getMagic().

◆ emphasize()

Language::emphasize (   $text)

Italic is unsuitable for some languages.

Parameters
$textString: the text to be emphasized.
Returns
string

Reimplemented in LanguageJa.

Definition at line 3067 of file Language.php.

◆ factory()

static Language::factory (   $code)
static

Get a cached or new language object for a given language code.

Parameters
$codeString
Returns
Language

Definition at line 184 of file Language.php.

References array(), global, and newFromCode().

Referenced by UppercaseCollation\__construct(), IcuCollation\__construct(), CollationCkb\__construct(), StubContLang\_newObject(), BackupDumperPageTest\addDBData(), MessageCacheTest\configureLanguages(), ApiParse\execute(), ApiQueryAllMessages\execute(), DateFormats\execute(), LangMemUsage\execute(), PurgeParserCache\execute(), UpdateMediaWiki\execute(), RCCacheEntryFactoryTest\getContext(), ResourceLoaderContext\getDirection(), RequestContext\getLanguage(), ResourceLoaderLanguageDataModule\getModifiedHash(), ContentHandler\getPageViewLanguage(), Title\getPageViewLanguage(), getParentLanguage(), ResourceLoaderLanguageDataModule\getScript(), MediaWikiTitleCodecTest\makeCodec(), LoginForm\makeLanguageSelectorLink(), LoginForm\processLogin(), MessageTest\provideConstructor(), DerivativeContext\setLanguage(), RequestContext\setLanguage(), MessageTest\setUp(), RevisionTest\setUp(), LanguageConverterTest\setUp(), MediaWikiLangTestCase\setUp(), MWTimestampTest\setUp(), TestSample\setUp(), XmlTest\setUp(), TitleTest\setUp(), ExtraParserTest\setUp(), SpecialPageTest\setUp(), BlockTest\setUp(), TitlePermissionTest\setUp(), MediaWikiTitleCodecTest\setUp(), MagicVariableTest\setUp(), SideBarTest\setUp(), LanguageClassesTestCase\setUp(), WebInstaller\setupLanguage(), ParserOptions\setUserLang(), ArticleTablesTest\testbug14404(), MessageTest\testGetLanguageCode(), LanguageTest\testGetNamespaceAliases(), TitleTest\testGetPageViewLanguage(), LanguageTest\testGetParentLanguage(), LanguageConverterTest\testGetPreferredVariantDefaultLanguageVsUrlVariant(), LanguageConverterTest\testGetPreferredVariantHeaderUserVsUrl(), LanguageConverterTest\testGetPreferredVariantUserOptionForForeignLanguage(), MessageTest\testInContentLanguageDisabled(), MessageTest\testInContentLanguageEnabled(), MessageTest\testInLanguage(), MessageTest\testMessageBitrateParams(), MessageTest\testMessageDurationParams(), MessageTest\testMessageExpiryParams(), MessageTest\testMessageNumParams(), MessageTest\testMessageSizeParams(), MessageTest\testMessageTimeperiodParams(), SpecialPageTest\testRequireLoginAnon(), ApiWatch\watchTitle(), and wfInstallerMain().

◆ fallback8bitEncoding()

Language::fallback8bitEncoding ( )
Returns
array

Definition at line 2636 of file Language.php.

Referenced by checkTitleEncoding().

◆ fetchLanguageName()

static Language::fetchLanguageName (   $code,
  $inLanguage = null,
  $include = 'all' 
)
static
Parameters
$codestring: The code of the language for which to get the name
$inLanguagenull|string: Code of language in which to return the name (null for autonyms)
$includestring: 'all', 'mw' or 'mwfile'; see fetchLanguageNames()
Returns
string: Language name or empty
Since
1.20

Definition at line 936 of file Language.php.

References fetchLanguageNames().

Referenced by ImagePage\doRenderLangOpt(), ApiQueryLangLinks\execute(), MessageCache\figureMessage(), ApiParse\formatLangLinks(), getLanguageName(), SkinTemplate\getLanguages(), getVariantname(), WikiStatsOutput\heading(), FormatMetadata\langItem(), CoreParserFunctions\language(), ApiParse\languagesHtml(), FormatMetadata\makeFormattedData(), WikitextContentHandler\makeRedirectContent(), and InfoAction\pageInfo().

◆ fetchLanguageNames()

static Language::fetchLanguageNames (   $inLanguage = null,
  $include = 'mw' 
)
static

Get an array of language names, indexed by code.

Parameters
$inLanguagenull|string: Code of language in which to return the names Use null for autonyms (native names)
$includestring: 'all' all available languages 'mw' only if the language is defined in MediaWiki or wgExtraLanguageNames (default) 'mwfile' only if the language is in 'mw' and has a message file
Returns
array: language code => language name
Since
1.20

Definition at line 875 of file Language.php.

Referenced by MessageCache\clear(), RebuildLocalisationCache\execute(), DeleteEqualMessages\execute(), fetchLanguageName(), WebInstaller\getAcceptLanguage(), Xml\languageSelector(), Preferences\profilePreferences(), MessageCache\replace(), and SpecialPageAliasTest\validSpecialPageAliasesProvider().

◆ findVariantLink()

Language::findVariantLink ( $link,
$nt,
  $ignoreOtherCond = false 
)

If a language supports multiple variants, it is possible that non-existing link in one variant actually exists in another variant.

this function tries to find it. See e.g. LanguageZh.php

Parameters
$linkString: the name of the link
$ntMixed: the title object of the link
$ignoreOtherCondBoolean: to disable other conditions when we need to transclude a template or update a category's link
Returns
null the input parameters may be modified upon return

Definition at line 3908 of file Language.php.

References $link.

◆ firstChar()

Language::firstChar (   $s)

Get the first character of a string.

Parameters
$sstring
Returns
string

Definition at line 2724 of file Language.php.

References $matches, $s, array(), and utf8ToCodepoint().

◆ fixVariableInNamespace()

Language::fixVariableInNamespace (   $talk)
Parameters
$talk
Returns
mixed

Definition at line 4224 of file Language.php.

References array(), and global.

Referenced by getNamespaceAliases(), and getNamespaces().

◆ formatBitrate()

Language::formatBitrate (   $bps)

Format a bitrate for output, using an appropriate unit (bps, kbps, Mbps, Gbps, Tbps, Pbps, Ebps, Zbps or Ybps) according to the magnitude in question.

This use base 1000. For base 1024 use formatSize(), for another base see formatComputingNumbers()

Parameters
$bpsint
Returns
string

Definition at line 4408 of file Language.php.

References formatComputingNumbers().

◆ formatComputingNumbers()

Language::formatComputingNumbers (   $size,
  $boundary,
  $messageKey 
)
Parameters
$sizeint Size of the unit
$boundaryint Size boundary (1000, or 1024 in most cases)
$messageKeystring Message key to be uesd
Returns
string

Definition at line 4418 of file Language.php.

References $size, array(), formatNum(), and getMessageFromDB().

Referenced by formatBitrate(), and formatSize().

◆ formatDuration()

Language::formatDuration (   $seconds,
array  $chosenIntervals = array() 
)

Takes a number of seconds and turns it into a text using values such as hours and minutes.

Since
1.20
Parameters
integer$secondsThe amount of seconds.
array$chosenIntervalsThe intervals to enable.
Returns
string

Reimplemented in LanguageZh_hans.

Definition at line 2103 of file Language.php.

References array(), as, getDurationIntervals(), listToText(), and wfMessage().

Referenced by translateBlockExpiry().

◆ formatExpiry()

Language::formatExpiry (   $expiry,
  $format = true 
)

Decode an expiry (block, protection, etc) which has come from the DB.

Todo:
FIXME: why are we returnings DBMS-dependent strings???
Parameters
$expiryString: Database expiry String
$formatBool|Int true to process using language functions, or TS_ constant to return the expiry in a given timestamp
Returns
String
Since
1.18

Definition at line 4282 of file Language.php.

References DB_SLAVE, getMessageFromDB(), timeanddate(), wfGetDB(), and wfTimestamp().

◆ formatNum()

Language::formatNum (   $number,
  $nocommafy = false 
)

Normally we output all numbers in plain en_US style, that is 293,291.235 for twohundredninetythreethousand-twohundredninetyone point twohundredthirtyfive.

However this is not suitable for all languages, some such as Punjabi want ੨੯੩,੨੯੫.੨੩੫ and others such as Icelandic just want to use commas instead of dots, and dots instead of commas like "293.291,235".

An example of this function being called: wfMessage( 'message' )->numParams( $num )->text()

See $separatorTransformTable on MessageIs.php for the , => . and . => , implementation.

Todo:
check if it's viable to use localeconv() for the decimal separator thing.
Parameters
$numberMixed: the string to be formatted, should be an integer or a floating point number.
$nocommafyBool: set to true for special numbers like dates
Returns
string

Definition at line 3094 of file Language.php.

References $s, commafy(), digitTransformTable(), global, and separatorTransformTable().

Referenced by formatComputingNumbers(), formatNumNoSeparators(), formatTimePeriod(), sprintfDate(), and viewPrevNext().

◆ formatNumNoSeparators()

Language::formatNumNoSeparators (   $number)

Front-end for non-commafied formatNum.

Parameters
mixed$numberthe string to be formatted, should be an integer or a floating point number.
Since
1.21
Returns
string

Definition at line 3122 of file Language.php.

References formatNum().

◆ formatSize()

Language::formatSize (   $size)

Format a size in bytes for output, using an appropriate unit (B, KB, MB, GB, TB, PB, EB, ZB or YB) according to the magnitude in question.

This method use base 1024. For base 1000 use formatBitrate(), for another base see formatComputingNumbers()

Parameters
$sizeint Size to format
Returns
string Plain text (not HTML)

Definition at line 4456 of file Language.php.

References $size, and formatComputingNumbers().

◆ formatTimePeriod()

Language::formatTimePeriod (   $seconds,
  $format = array() 
)
Todo:
Document
Parameters
$secondsint|float
$formatArray Optional If $format['avoid'] == 'avoidseconds' - don't mention seconds if $seconds >= 1 hour If $format['avoid'] == 'avoidminutes' - don't mention seconds/minutes if $seconds > 48 hours If $format['noabbrevs'] is true - use 'seconds' and friends instead of 'seconds-abbrev' and friends For backwards compatibility, $format may also be one of the strings 'avoidseconds' or 'avoidminutes'
Returns
string

Definition at line 4309 of file Language.php.

References $s, array(), formatNum(), and wfMessage().

◆ gender()

Language::gender (   $gender,
  $forms 
)

Provides an alternative text depending on specified gender.

Usage {{gender:username|masculine|feminine|unknown}}. username is optional, in which case the gender of current user is used, but only in (some) interface messages; otherwise default gender is used.

If no forms are given, an empty string is returned. If only one form is given, it will be returned unconditionally. These details are implied by the caller and cannot be overridden in subclasses.

If three forms are given, the default is to use the third (unknown) form. If fewer than three forms are given, the default is to use the first (masculine) form. These details can be overridden in subclasses.

Parameters
$genderstring
$formsarray
Returns
string

Definition at line 3609 of file Language.php.

References preConvertPlural().

◆ getAllMessages()

Language::getAllMessages ( )
Returns
array

Definition at line 2346 of file Language.php.

◆ getArrow()

Language::getArrow (   $direction = 'forwards')

An arrow, depending on the language direction.

Parameters
$directionString: the direction of the arrow: forwards (default), backwards, left, right, up, down.
Returns
string

Definition at line 2956 of file Language.php.

References isRTL().

◆ getBookstoreList()

Language::getBookstoreList ( )

Exports $wgBookstoreListEn.

Returns
array

Definition at line 500 of file Language.php.

◆ getCaseMaps()

static Language::getCaseMaps ( )
static
Exceptions
MWException
Returns
array

Definition at line 4253 of file Language.php.

References array(), wfGetPrecompiledData(), wfProfileIn(), and wfProfileOut().

Referenced by lcCallback(), ucCallback(), and ucwordsCallbackWiki().

◆ getClassFileName()

static Language::getClassFileName (   $code)
static
Parameters
$codestring
Returns
string

Definition at line 4111 of file Language.php.

References $IP, getFileName(), and global.

◆ getCode()

Language::getCode ( )

Get the RFC 3066 code for this language object.

NOTE: The return value of this function is NOT HTML-safe and must be escaped with htmlspecialchars() or similar

Returns
string

Definition at line 4017 of file Language.php.

References $mCode.

Referenced by LanguageHu\convertGrammar(), convertGrammar(), doMagicHook(), getGrammarForms(), getHtmlCode(), getParentLanguage(), and getSpecialPageAliases().

◆ getCodeFromFileName()

static Language::getCodeFromFileName (   $filename,
  $prefix = 'Language',
  $suffix = '.php' 
)
static

Get the language code from a file name.

Inverse of getFileName()

Parameters
$filenamestring $prefix . $languageCode . $suffix
$prefixstring Prefix before the language code
$suffixstring Suffix after the language code
Returns
string Language code, or false if $prefix or $suffix isn't found

Definition at line 4071 of file Language.php.

◆ getCompiledPluralRules()

Language::getCompiledPluralRules ( )

Get the compiled plural rules for the language.

Since
1.20
Returns
array Associative array with plural form, and plural rule as key-value pairs

Definition at line 4552 of file Language.php.

References as, and getFallbacksFor().

Referenced by getPluralRuleIndexNumber().

◆ getConverter()

Language::getConverter ( )

Return the LanguageConverter used in the Language.

Since
1.19
Returns
LanguageConverter

Definition at line 3771 of file Language.php.

References $mConverter.

Referenced by getNamespaceAliases().

◆ getConvRuleTitle()

Language::getConvRuleTitle ( )

Get the conversion rule title, if any.

Returns
string

Definition at line 4543 of file Language.php.

◆ getDateFormats()

Language::getDateFormats ( )
Returns
array

Definition at line 790 of file Language.php.

◆ getDateFormatString()

Language::getDateFormatString (   $type,
  $pref 
)

Get a format string for a given type and preference.

Parameters
$typestring May be date, time or both
$prefstring The format name as it appears in Messages*.php
Since
1.22 New type 'pretty' that provides a more readable timestamp format
Returns
string

Definition at line 2013 of file Language.php.

References $type, and getDefaultDateFormat().

Referenced by date(), getHumanTimestamp(), internalUserTimeAndDate(), time(), and timeanddate().

◆ getDatePreferenceMigrationMap()

Language::getDatePreferenceMigrationMap ( )
Returns
array

Definition at line 810 of file Language.php.

◆ getDatePreferences()

Language::getDatePreferences ( )
Returns
array

Definition at line 783 of file Language.php.

◆ getDefaultDateFormat()

Language::getDefaultDateFormat ( )
Returns
array|string

Definition at line 797 of file Language.php.

Referenced by getDateFormatString().

◆ getDefaultVariant()

Language::getDefaultVariant ( )
Returns
string

Definition at line 3885 of file Language.php.

◆ getDir()

Language::getDir ( )

Return the correct HTML 'dir' attribute value for this language.

Returns
String

Definition at line 2878 of file Language.php.

References isRTL().

◆ getDirMark()

Language::getDirMark (   $opposite = false)

A hidden direction mark (LRM or RLM), depending on the language direction.

This function produces them as invisible Unicode characters and the output may be hard to read and debug, so it should only be used when the output is plain text or can be escaped. When the output is HTML, use getDirMarkEntity() instead.

Parameters
$oppositeBoolean Get the direction mark opposite to your language
Returns
string

Definition at line 2934 of file Language.php.

References isRTL(), cssjanus\LEFT, and cssjanus\RIGHT.

Referenced by specialList().

◆ getDirMarkEntity()

Language::getDirMarkEntity (   $opposite = false)

A hidden direction mark (LRM or RLM), depending on the language direction.

Unlike getDirMark(), this function returns the character as an HTML entity. This function should be used when the output is guaranteed to be HTML, because it makes the output HTML source code more readable. When the output is plain text or can be escaped, getDirMark() should be used.

Parameters
$oppositeBoolean Get the direction mark opposite to your language
Returns
string
Since
1.20

Definition at line 2917 of file Language.php.

References isRTL().

◆ getDurationIntervals()

Language::getDurationIntervals (   $seconds,
array  $chosenIntervals = array() 
)

Takes a number of seconds and returns an array with a set of corresponding intervals.

For example 65 will be turned into array( minutes => 1, seconds => 5 ).

Since
1.20
Parameters
integer$secondsThe amount of seconds.
array$chosenIntervalsThe intervals to enable.
Returns
array

Definition at line 2129 of file Language.php.

References $name, $value, array(), and as.

Referenced by LanguageZh_hans\formatDuration(), and formatDuration().

◆ getExtraHashOptions()

Language::getExtraHashOptions ( )

returns language specific options used by User::getPageRenderHash() for example, the preferred language variant

Returns
string

Definition at line 3918 of file Language.php.

◆ getExtraUserToggles()

Language::getExtraUserToggles ( )
Returns
array

Definition at line 825 of file Language.php.

◆ getFallbackFor()

static Language::getFallbackFor (   $code)
static

Get the first fallback for a given language.

Parameters
$codestring
Returns
bool|string

Definition at line 4123 of file Language.php.

References getFallbacksFor(), and isValidBuiltInCode().

Referenced by getFallbackLanguageCode().

◆ getFallbackLanguageCode()

Language::getFallbackLanguageCode ( )

Same as getFallbacksFor for current language.

Returns
array|bool
Deprecated:
in 1.19

Definition at line 483 of file Language.php.

References getFallbackFor(), and wfDeprecated().

◆ getFallbackLanguages()

Language::getFallbackLanguages ( )
Returns
array
Since
1.19

Definition at line 492 of file Language.php.

References getFallbacksFor().

Referenced by addMagicWordsByLang().

◆ getFallbacksFor()

static Language::getFallbacksFor (   $code)
static

Get the ordered list of fallback languages.

Since
1.19
Parameters
$codestring Language code
Returns
array

Definition at line 4140 of file Language.php.

References array(), getLocalisationCache(), and isValidBuiltInCode().

Referenced by getCompiledPluralRules(), getFallbackFor(), getFallbackLanguages(), getFallbacksIncludingSiteLanguage(), getPluralRules(), getPluralRuleTypes(), and newFromCode().

◆ getFallbacksIncludingSiteLanguage()

static Language::getFallbacksIncludingSiteLanguage (   $code)
static

Get the ordered list of fallback languages, ending with the fallback language chain for the site language.

Since
1.22
Parameters
string$codeLanguage code
Returns
array array( fallbacks, site fallbacks )

Definition at line 4161 of file Language.php.

References array(), getFallbacksFor(), and global.

Referenced by MessageCache\getMessageFromFallbackChain(), and FormatMetadata\getPriorityLanguages().

◆ getFileName()

static Language::getFileName (   $prefix = 'Language',
  $code,
  $suffix = '.php' 
)
static

Get the name of a file for a certain language code.

Parameters
$prefixstring Prepend this to the filename
$codestring Language code
$suffixstring Append this to the filename
Exceptions
MWException
Returns
string $prefix . $mangledCode . $suffix

Definition at line 4056 of file Language.php.

References ucfirst().

Referenced by getClassFileName(), getMessagesFileName(), and MessageWriter\writeMessagesToFile().

◆ getFormattedNamespaces()

Language::getFormattedNamespaces ( )

A convenience function that returns the same thing as getNamespaces() except with the array values changed to ' ' where it found '_', useful for producing output to be displayed e.g.

in <select> forms.

Returns
array

Definition at line 570 of file Language.php.

References as, and getNamespaces().

◆ getFormattedNsText()

Language::getFormattedNsText (   $index)

A convenience function that returns the same thing as getNsText() except with '_' changed to ' ', useful for producing output.

$mw_ns = $wgContLang->getFormattedNsText( NS_MEDIAWIKI_TALK ); echo $mw_ns; // prints 'MediaWiki talk'

Parameters
int$indexThe array key of the namespace to return
Returns
string Namespace name without underscores (empty string if namespace does not exist)

Definition at line 606 of file Language.php.

References getNsText().

◆ getGenderNsText()

Language::getGenderNsText (   $index,
  $gender 
)

Returns gender-dependent namespace alias if available.

See https://www.mediawiki.org/wiki/Manual:$wgExtraGenderNamespaces

Parameters
$indexInt: namespace index
$genderString: gender key (male, female... )
Returns
String
Since
1.18

Definition at line 619 of file Language.php.

References getNsText(), and global.

◆ getGrammarForms()

Language::getGrammarForms ( )

Get the grammar forms for the content language.

Returns
array of grammar forms
Since
1.20

Definition at line 3583 of file Language.php.

References array(), getCode(), and global.

◆ getHebrewCalendarMonthName()

Language::getHebrewCalendarMonthName (   $key)
Parameters
$keystring
Returns
string

Definition at line 1037 of file Language.php.

References getMessageFromDB().

Referenced by sprintfDate().

◆ getHebrewCalendarMonthNameGen()

Language::getHebrewCalendarMonthNameGen (   $key)
Parameters
$keystring
Returns
string

Definition at line 1045 of file Language.php.

References getMessageFromDB().

Referenced by sprintfDate().

◆ getHijriCalendarMonthName()

Language::getHijriCalendarMonthName (   $key)
Parameters
$keystring
Returns
string

Definition at line 1053 of file Language.php.

References getMessageFromDB().

Referenced by sprintfDate().

◆ getHtmlCode()

Language::getHtmlCode ( )

Get the code in Bcp47 format which we can use inside of html lang="" tags.

NOTE: The return value of this function is NOT HTML-safe and must be escaped with htmlspecialchars() or similar.

Since
1.19
Returns
string

Definition at line 4031 of file Language.php.

References $mHtmlCode, getCode(), and wfBCP47().

◆ getHumanTimestamp()

Language::getHumanTimestamp ( MWTimestamp  $ts,
MWTimestamp  $relativeTo,
User  $user 
)

Convert an MWTimestamp into a pretty human-readable timestamp using the given user preferences and relative base time.

DO NOT USE THIS FUNCTION DIRECTLY. Instead, call MWTimestamp::getHumanTimestamp on your timestamp object, which will then call this function. Calling this function directly will cause hooks to be skipped over.

See also
MWTimestamp::getHumanTimestamp
Parameters
MWTimestamp$tsTimestamp to prettify
MWTimestamp$relativeToBase timestamp
User$userUser preferences to use
Returns
string Human timestamp
Since
1.22

Definition at line 2275 of file Language.php.

References MWTimestamp\diff(), MWTimestamp\format(), getDateFormatString(), User\getDatePreference(), MWTimestamp\getTimestamp(), sprintfDate(), TS_MW, and wfMessage().

◆ getImageFile()

Language::getImageFile (   $image)
Parameters
$image
Returns
array|null

Definition at line 818 of file Language.php.

◆ getIranianCalendarMonthName()

Language::getIranianCalendarMonthName (   $key)
Parameters
$keystring
Returns
string

Definition at line 1029 of file Language.php.

References getMessageFromDB().

Referenced by sprintfDate().

◆ getJsonMessagesFileName()

static Language::getJsonMessagesFileName (   $code)
static
Parameters
$codestring
Returns
string
Since
1.23

Definition at line 4097 of file Language.php.

References $IP, and global.

◆ getLangObj()

Language::getLangObj ( )
Returns
Language

Definition at line 3977 of file Language.php.

◆ getLanguageName()

Language::getLanguageName (   $code)

Get the native language name of $code.

Only if defined in MediaWiki, no other data like CLDR.

Parameters
$codestring
Returns
string
Deprecated:
in 1.20, use fetchLanguageName()

Definition at line 959 of file Language.php.

References fetchLanguageName().

◆ getLanguageNames()

static Language::getLanguageNames (   $customisedOnly = false)
static

Get native language names, indexed by code.

Only those defined in MediaWiki, no other data like CLDR. If $customisedOnly is true, only returns codes with a messages file

Parameters
$customisedOnlybool
Returns
array
Deprecated:
in 1.20, use fetchLanguageNames()

Definition at line 847 of file Language.php.

◆ getLocalisationCache()

◆ getLocalNsIndex()

Language::getLocalNsIndex (   $text)

Get a namespace key by value, case insensitive.

Only matches namespace names for the current language, not the canonical ones defined in Namespace.php.

Parameters
$textString
Returns
mixed An integer if $text is a valid value otherwise false

Definition at line 656 of file Language.php.

References getNamespaceIds(), and lc().

◆ getMagic()

Language::getMagic (   $mw)

Fill a MagicWord object with data from here.

Parameters
$mw

Definition at line 3008 of file Language.php.

References doMagicHook().

◆ getMagicWords()

Language::getMagicWords ( )

Get all magic words from cache.

Returns
array

Definition at line 2986 of file Language.php.

◆ getMessage()

Language::getMessage (   $key)
Parameters
$keystring
Returns
array|null

Reimplemented in LanguageQqx.

Definition at line 2339 of file Language.php.

◆ getMessageFor()

static Language::getMessageFor (   $key,
  $code 
)
static

Get a message for a given language.

Parameters
$keystring
$codestring
Returns
string

Definition at line 4204 of file Language.php.

References getLocalisationCache().

Referenced by MessageCache\get().

◆ getMessageFromDB()

◆ getMessageKeysFor()

static Language::getMessageKeysFor (   $code)
static

Get all message keys for a given language.

This is a faster alternative to array_keys( Language::getMessagesFor( $code ) )

Since
1.19
Parameters
$codestring Language code
Returns
array of message keys (strings)

Definition at line 4216 of file Language.php.

References getLocalisationCache().

Referenced by ApiQueryAllMessages\execute(), and UserTest\testAllRightsWithMessage().

◆ getMessagesFileName()

static Language::getMessagesFileName (   $code)
static

◆ getMessagesFor()

static Language::getMessagesFor (   $code)
static

Get all messages for a given language WARNING: this may take a long time.

If you just need all message keys but need the contents of only a few messages, consider using getMessageKeysFor().

Parameters
$codestring
Returns
array

Definition at line 4192 of file Language.php.

References getLocalisationCache().

Referenced by AllTrans\execute(), and DumpMessages\execute().

◆ getMonthAbbreviation()

Language::getMonthAbbreviation (   $key)
Parameters
$keystring
Returns
string

Definition at line 994 of file Language.php.

References getMessageFromDB().

Referenced by getMonthAbbreviationsArray(), and sprintfDate().

◆ getMonthAbbreviationsArray()

Language::getMonthAbbreviationsArray ( )
Returns
array

Definition at line 1001 of file Language.php.

References array(), and getMonthAbbreviation().

◆ getMonthName()

Language::getMonthName (   $key)
Parameters
$keystring
Returns
string

Definition at line 967 of file Language.php.

References getMessageFromDB().

Referenced by LanguageWa\date(), getMonthNamesArray(), and sprintfDate().

◆ getMonthNameGen()

Language::getMonthNameGen (   $key)
Parameters
$keystring
Returns
string

Definition at line 986 of file Language.php.

References getMessageFromDB().

Referenced by sprintfDate().

◆ getMonthNamesArray()

Language::getMonthNamesArray ( )
Returns
array

Definition at line 974 of file Language.php.

References array(), and getMonthName().

◆ getNamespaceAliases()

Language::getNamespaceAliases ( )

◆ getNamespaceIds()

Language::getNamespaceIds ( )
Returns
array

Definition at line 707 of file Language.php.

References $mNamespaceIds, $name, $wgNamespaceAliases, array(), as, getNamespaceAliases(), getNamespaces(), global, and lc().

Referenced by getLocalNsIndex(), and getNsIndex().

◆ getNamespaces()

Language::getNamespaces ( )

Returns an array of localised namespaces indexed by their numbers.

If the namespace is not available in localised form, it will be included in English.

Returns
array

Definition at line 510 of file Language.php.

References $namespaceNames, array(), as, fixVariableInNamespace(), MWNamespace\getCanonicalNamespaces(), global, NS_PROJECT, NS_PROJECT_TALK, and wfRunHooks().

Referenced by getFormattedNamespaces(), getNamespaceAliases(), getNamespaceIds(), and getNsText().

◆ getNsIndex()

Language::getNsIndex (   $text)

Get a namespace key by value, case insensitive.

Canonical namespace names override custom ones defined for the current language.

Parameters
$textString
Returns
mixed An integer if $text is a valid value otherwise false

Definition at line 737 of file Language.php.

References MWNamespace\getCanonicalIndex(), getNamespaceIds(), and lc().

◆ getNsText()

Language::getNsText (   $index)

Get a namespace value by key $mw_ns = $wgContLang->getNsText( NS_MEDIAWIKI ); echo $mw_ns; // prints 'MediaWiki'

Parameters
$indexInt: the array key of the namespace to return
Returns
mixed, string if the namespace value exists, otherwise false

Definition at line 588 of file Language.php.

References getNamespaces().

Referenced by getFormattedNsText(), and getGenderNsText().

◆ getParentLanguage()

Language::getParentLanguage ( )

Get the "parent" language which has a converter to convert a "compatible" language (in another variant) to this language (eg.

zh for zh-cn, but not en for en-gb).

Returns
Language|null
Since
1.22

Definition at line 3988 of file Language.php.

References $mParentLanguage, factory(), and getCode().

◆ getParsedTitle()

Language::getParsedTitle ( )

For languages that support multiple variants, the title of an article may be displayed differently in different variants.

this function returns the apporiate title defined in the body of the article.

Returns
string

Definition at line 3929 of file Language.php.

◆ getPluralRuleIndexNumber()

Language::getPluralRuleIndexNumber (   $number)

Find the index number of the plural rule appropriate for the given number.

Returns
int The index number of the plural rule

Definition at line 4608 of file Language.php.

References $form, CLDRPluralRuleEvaluator\evaluateCompiled(), and getCompiledPluralRules().

Referenced by convertPlural(), and getPluralRuleType().

◆ getPluralRules()

Language::getPluralRules ( )

Get the plural rules for the language.

Since
1.20
Returns
array Associative array with plural form number and plural rule as key-value pairs

Definition at line 4571 of file Language.php.

References as, and getFallbacksFor().

◆ getPluralRuleType()

Language::getPluralRuleType (   $number)

Find the plural rule type appropriate for the given number For example, if the language is set to Arabic, getPluralType(5) should return 'few'.

Since
1.22
Returns
string The name of the plural rule type, e.g. one, two, few, many

Definition at line 4621 of file Language.php.

References getPluralRuleIndexNumber(), and getPluralRuleTypes().

◆ getPluralRuleTypes()

Language::getPluralRuleTypes ( )

Get the plural rule types for the language.

Since
1.22
Returns
array Associative array with plural form number and plural rule type as key-value pairs

Definition at line 4590 of file Language.php.

References as, and getFallbacksFor().

Referenced by getPluralRuleType().

◆ getPreferredVariant()

Language::getPreferredVariant ( )
Returns
string

Definition at line 3878 of file Language.php.

Referenced by LanguageKk\convertGrammar(), LanguageKk\lcfirst(), and LanguageKk\ucfirst().

◆ getSpecialPageAliases()

Language::getSpecialPageAliases ( )

Get special page names, as an associative array case folded alias => real name.

Definition at line 3048 of file Language.php.

References $mExtendedSpecialPageAliases, array(), getCode(), and wfRunHooks().

◆ getTranslatedLanguageNames()

static Language::getTranslatedLanguageNames (   $code)
static

Get translated language names.

This is done on best effort and by default this is exactly the same as Language::getLanguageNames. The CLDR extension provides translated names.

Parameters
$codeString Language code.
Returns
Array language code => language name
Since
1.18.0
Deprecated:
in 1.20, use fetchLanguageNames()

Definition at line 860 of file Language.php.

◆ getURLVariant()

Language::getURLVariant ( )
Returns
string

Definition at line 3892 of file Language.php.

◆ getUserToggle()

Language::getUserToggle (   $tog)
Parameters
$tog
Returns
string

Definition at line 833 of file Language.php.

◆ getVariantname()

Language::getVariantname (   $code,
  $usemsg = true 
)

short names for language variants used for language conversion links.

Parameters
$codeString
$usemsgbool Use the "variantname-xyz" message if it exists
Returns
string

Definition at line 754 of file Language.php.

References $name, fetchLanguageName(), getMessageFromDB(), and wfMessage().

◆ getVariants()

Language::getVariants ( )

Get the list of variants supported by this language see sample implementation in LanguageZh.php.

Returns
array an array of language codes

Definition at line 3871 of file Language.php.

Referenced by getNamespaceAliases(), and hasVariants().

◆ getWeekdayAbbreviation()

Language::getWeekdayAbbreviation (   $key)
Parameters
$keystring
Returns
string

Definition at line 1021 of file Language.php.

References getMessageFromDB().

Referenced by sprintfDate().

◆ getWeekdayName()

Language::getWeekdayName (   $key)
Parameters
$keystring
Returns
string

Definition at line 1013 of file Language.php.

References getMessageFromDB().

Referenced by sprintfDate().

◆ handleExplicitPluralForms()

Language::handleExplicitPluralForms (   $count,
array  $forms 
)
protected

Handles explicit plural forms for Language::convertPlural()

In {{PLURAL:$1|0=nothing|one|many}}, 0=nothing will be returned if $1 equals zero. If an explicitly defined plural form matches the $count, then string value returned, otherwise array returned for further consideration by CLDR rules or overridden convertPlural().

Since
1.23
Parameters
int$countnon-localized number
array$formsdifferent plural forms
Returns
array|string

Definition at line 3668 of file Language.php.

References $count, $form, and as.

Referenced by LanguageKsh\convertPlural(), and convertPlural().

◆ hasVariant()

Language::hasVariant (   $variant)

Check if the language has the specific variant.

Since
1.19
Parameters
$variantstring
Returns
bool

Definition at line 3831 of file Language.php.

◆ hasVariants()

Language::hasVariants ( )

Check if this is a language with variants.

Returns
bool

Definition at line 3820 of file Language.php.

References getVariants().

◆ hasWordBreaks()

Language::hasWordBreaks ( )

Most writing systems use whitespace to break up words.

Some languages such as Chinese don't conventionally do this, which requires special handling when breaking up words for searching etc.

Returns
bool

Reimplemented in LanguageYue, and LanguageZh_hans.

Definition at line 2648 of file Language.php.

◆ hebrewNumeral()

static Language::hebrewNumeral (   $num)
static

Hebrew Gematria number formatting up to 9999.

Parameters
$numint
Returns
string

Definition at line 1834 of file Language.php.

References $s, and array().

Referenced by sprintfDate().

◆ hebrewYearStart()

static Language::hebrewYearStart (   $year)
staticprivate

This calculates the Hebrew year start, as days since 1 September.

Based on Carl Friedrich Gauss algorithm for finding Easter date. Used for Hebrew date.

Parameters
$yearint
Returns
string

Definition at line 1689 of file Language.php.

Referenced by tsToHebrew().

◆ iconv()

Language::iconv (   $in,
  $out,
  $string 
)
Parameters
$in
$out
$string
Returns
string

Reimplemented in LanguageEo.

Definition at line 2356 of file Language.php.

References $in, $out, wfRestoreWarnings(), and wfSuppressWarnings().

Referenced by checkTitleEncoding(), recodeForEdit(), and recodeInput().

◆ initContLang()

Language::initContLang ( )

Hook which will be called if this is the content language.

Descendants can use this to register hook functions or modify globals

Definition at line 476 of file Language.php.

◆ initEncoding()

Language::initEncoding ( )

Reimplemented in LanguageEo.

Definition at line 2776 of file Language.php.

◆ insertSpace()

static Language::insertSpace (   $string,
  $pattern 
)
staticprotected
Parameters
$stringstring
$patternstring
Returns
string

Definition at line 2702 of file Language.php.

Referenced by LanguageJa\segmentByWord(), LanguageYue\segmentByWord(), and LanguageZh_hans\segmentByWord().

◆ internalUserTimeAndDate()

Language::internalUserTimeAndDate (   $type,
  $ts,
User  $user,
array  $options 
)
private

Internal helper function for userDate(), userTime() and userTimeAndDate()

Parameters
$typeString: can be 'date', 'time' or 'both'
$tsMixed: the time format which needs to be turned into a date('YmdHis') format with wfTimestamp(TS_MW,$ts)
$userUser object used to get preferences for timezone and format
$optionsArray, can contain the following keys:
  • 'timecorrection': time correction, can have the following values:
    • true: use user's preference
    • false: don't use time correction
    • integer: value of time correction in minutes
  • 'format': format to use, can have the following values:
    • true: use user's preference
    • false: use default preference
    • string: format to use
Since
1.19
Returns
String

Definition at line 2171 of file Language.php.

References $options, $type, $user, array(), dateFormat(), getDateFormatString(), sprintfDate(), TS_MW, userAdjust(), and wfTimestamp().

Referenced by userDate(), userTime(), and userTimeAndDate().

◆ isKnownLanguageTag()

static Language::isKnownLanguageTag (   $tag)
static

Returns true if a language code is an IETF tag known to MediaWiki.

Parameters
$codestring
Since
1.21
Returns
bool

Definition at line 386 of file Language.php.

References $coreLanguageNames, $IP, and global.

Referenced by LanguageTest\testKnownCldrLanguageTag(), LanguageTest\testKnownLanguageTag(), and LanguageTest\testUnknownLanguageTag().

◆ isMultibyte()

Language::isMultibyte (   $str)
Parameters
$strstring
Returns
bool

Definition at line 2527 of file Language.php.

Referenced by lc(), uc(), ucwordbreaks(), and ucwords().

◆ isRTL()

Language::isRTL ( )

For right-to-left language support.

Returns
bool

Definition at line 2870 of file Language.php.

Referenced by alignEnd(), alignStart(), getArrow(), getDir(), getDirMark(), and getDirMarkEntity().

◆ isSupportedLanguage()

static Language::isSupportedLanguage (   $code)
static

Checks whether any localisation is available for that language tag in MediaWiki (MessagesXx.php exists).

Parameters
string$codeLanguage tag (in lower case)
Returns
bool Whether language is supported
Since
1.21

Definition at line 261 of file Language.php.

References isValidBuiltInCode().

Referenced by ApiCreateAccount\execute(), LocalisationCache\initLanguage(), and LanguageTest\testIsSupportedLanguage().

◆ isValidBuiltInCode()

static Language::isValidBuiltInCode (   $code)
static

Returns true if a language code is of a valid form for the purposes of internal customisation of MediaWiki, via Messages*.php or *.json.

Parameters
$codestring
Exceptions
MWException
Since
1.18
Returns
bool

Definition at line 363 of file Language.php.

References $type.

Referenced by getFallbackFor(), getFallbacksFor(), LocalisationCache\initLanguage(), isSupportedLanguage(), newFromCode(), LanguageTest\testBuiltInCodeValidation(), and LanguageTest\testBuiltInCodeValidationRejectUnderscore().

◆ isValidCode()

static Language::isValidCode (   $code)
static

Returns true if a language code string is of a valid form, whether or not it exists.

This includes codes which are used solely for customisation via the MediaWiki namespace.

Parameters
$codestring
Returns
bool

Definition at line 337 of file Language.php.

References $cache, array(), and Title\getTitleInvalidRegex().

Referenced by ApiQueryAllMessages\execute(), newFromCode(), and RequestContext\sanitizeLangCode().

◆ isWellFormedLanguageTag()

static Language::isWellFormedLanguageTag (   $code,
  $lenient = false 
)
static

Returns true if a language code string is a well-formed language tag according to RFC 5646.

This function only checks well-formedness; it doesn't check that language, script or variant codes actually exist in the repositories.

Based on regexes by Mark Davis of the Unicode Consortium: http://unicode.org/repos/cldr/trunk/tools/java/org/unicode/cldr/util/data/langtagRegex.txt

Parameters
$codestring
$lenientboolean Whether to allow '_' as separator. The default is only '-'.
Returns
bool
Since
1.21

Definition at line 283 of file Language.php.

References $s.

Referenced by SVGReader\animateFilterAndLang(), LanguageTest\testLenientLanguageTag(), LanguageTest\testMalformedLanguageTag(), and LanguageTest\testWellFormedLanguageTag().

◆ lc()

Language::lc (   $str,
  $first = false 
)
Parameters
$strstring
$firstbool
Returns
mixed|string

Definition at line 2498 of file Language.php.

References array(), and isMultibyte().

Referenced by getLocalNsIndex(), getNamespaceIds(), getNsIndex(), lcfirst(), ucwordbreaks(), and ucwords().

◆ lcCallback()

Language::lcCallback (   $matches)
Parameters
$matchesarray
Returns
string

Definition at line 2401 of file Language.php.

References $matches, getCaseMaps(), and list.

◆ lcfirst()

Language::lcfirst (   $str)
Parameters
$strstring
Returns
mixed|string

Reimplemented in LanguageKk, LanguageKaa, and LanguageTr.

Definition at line 2479 of file Language.php.

References lc().

◆ linkPrefixCharset()

Language::linkPrefixCharset ( )

A regular expression character set to match legal word-prefixing characters which should be merged onto a link of the form foo[[bar]].

Returns
string

Definition at line 3970 of file Language.php.

◆ linkPrefixExtension()

Language::linkPrefixExtension ( )

To allow "foo[[bar]]" to extend the link over the whole word "foobar".

Returns
bool

Definition at line 2978 of file Language.php.

◆ linkTrail()

Language::linkTrail ( )

A regular expression to match legal word-trailing characters which should be merged onto a link of the form [[foo]]bar.

Returns
string

Definition at line 3960 of file Language.php.

◆ listToText()

Language::listToText ( array  $l)

Take a list of strings and build a locale-friendly comma-separated list, using the local comma-separator message.

The last two strings are chained with an "and". NOTE: This function will only work with standard numeric array keys (0, 1, 2…)

Parameters
$lArray
Returns
string

Definition at line 3230 of file Language.php.

References $s, and getMessageFromDB().

Referenced by formatDuration().

◆ markNoConversion()

Language::markNoConversion (   $text,
  $noParse = false 
)

Prepare external link text for conversion.

When the text is a URL, it shouldn't be converted, and it'll be wrapped in the "raw" tag (-{R| }-) to prevent conversion.

This function is called "markNoConversion" for historical reasons.

Parameters
$textString: text to be used for external link
$noParsebool: wrap it without confirming it's a real URL first
Returns
string the tagged text

Definition at line 3945 of file Language.php.

References wfUrlProtocolsWithoutProtRel().

◆ needsGenderDistinction()

Language::needsGenderDistinction ( )

Whether this language uses gender-dependent namespace aliases.

See https://www.mediawiki.org/wiki/Manual:$wgExtraGenderNamespaces

Returns
bool
Since
1.18

Definition at line 632 of file Language.php.

References global, NS_USER, and NS_USER_TALK.

◆ newFromCode()

static Language::newFromCode (   $code)
staticprotected

Create a language object for a given language code.

Parameters
$codeString
Exceptions
MWException
Returns
Language

Definition at line 210 of file Language.php.

References as, classFromCode(), getFallbacksFor(), isValidBuiltInCode(), isValidCode(), preloadLanguageClass(), and setCode().

Referenced by factory().

◆ normalize()

Language::normalize (   $s)

Convert a UTF-8 string to normal form C.

In Malayalam and Arabic, this also cleans up certain backwards-compatible sequences, converting them to the modern Unicode equivalent.

This is language-specific for performance reasons only.

Parameters
$sstring
Returns
string

Reimplemented in LanguageMl, and LanguageAr.

Definition at line 2829 of file Language.php.

References $s, UtfNormal\cleanUp(), global, and transformUsingPairFile().

◆ normalizeForSearch()

Language::normalizeForSearch (   $string)

Some languages have special punctuation need to be normalized.

Make such changes here.

Parameters
$stringString
Returns
String

Reimplemented in LanguageYue, LanguageBe_tarask, and LanguageZh_hans.

Definition at line 2670 of file Language.php.

References convertDoubleWidth().

◆ numLink()

Language::numLink ( Title  $title,
  $offset,
  $limit,
array  $query,
  $link,
  $tooltipMsg,
  $class 
)
private

Helper function for viewPrevNext() that generates links.

Parameters
$titleTitle object to link
$offsetInteger offset parameter
$limitInteger limit parameter
$queryArray extra query parameters
$linkString text to use for the link; will be escaped
$tooltipMsgString name of the message to use as tooltip
$classString value of the "class" attribute of the link
Returns
String HTML fragment

Definition at line 4531 of file Language.php.

References $limit, $link, $query, $title, array(), Html\element(), and wfMessage().

Referenced by viewPrevNext().

◆ parseFormattedNumber()

Language::parseFormattedNumber (   $number)
Parameters
$numberstring
Returns
string

Definition at line 3130 of file Language.php.

References $s, array(), digitTransformTable(), and separatorTransformTable().

◆ pipeList()

Language::pipeList ( array  $list)

Same as commaList, but separate it with the pipe instead.

Parameters
$listarray of strings to put in a pipe list
Returns
string

Definition at line 3284 of file Language.php.

References wfMessage().

Referenced by viewPrevNext().

◆ preConvertPlural()

Language::preConvertPlural (   $forms,
  $count 
)
protected

Checks that convertPlural was given an array and pads it to requested amount of forms by copying the last one.

Parameters
$countInteger: How many forms should there be at least
$formsArray of forms given to convertPlural
Returns
array Padded array of forms or an exception if not an array

Definition at line 3689 of file Language.php.

References $count.

Referenced by LanguageKsh\convertPlural(), and gender().

◆ preloadLanguageClass()

static Language::preloadLanguageClass (   $class)
static

Includes language class files.

Parameters
$classstring Name of the language class

Definition at line 426 of file Language.php.

References $IP, and global.

Referenced by newFromCode().

◆ recodeForEdit()

Language::recodeForEdit (   $s)
Parameters
$sstring
Returns
string

Definition at line 2787 of file Language.php.

References $s, global, and iconv().

◆ recodeInput()

Language::recodeInput (   $s)
Parameters
$sstring
Returns
string

Definition at line 2803 of file Language.php.

References $s, global, and iconv().

◆ removeBadCharFirst()

Language::removeBadCharFirst (   $string)
protected

Remove bytes that represent an incomplete Unicode character at the start of string (e.g.

bytes of the char are missing)

Parameters
$stringString
Returns
string

Definition at line 3382 of file Language.php.

Referenced by truncate().

◆ removeBadCharLast()

Language::removeBadCharLast (   $string)
protected

Remove bytes that represent an incomplete Unicode character at the end of string (e.g.

bytes of the char are missing)

Parameters
$stringString
Returns
string

Definition at line 3357 of file Language.php.

References array().

Referenced by truncate(), and truncateHtml().

◆ replaceGrammarInNamespace()

Language::replaceGrammarInNamespace (   $m)
Parameters
$mstring
Returns
string

Definition at line 4245 of file Language.php.

References convertGrammar().

◆ resetNamespaces()

Language::resetNamespaces ( )

Resets all of the namespace caches.

Mainly used for testing

Definition at line 556 of file Language.php.

◆ romanNumeral()

static Language::romanNumeral (   $num)
static

Roman number formatting up to 10000.

Parameters
$numint
Returns
string

Definition at line 1804 of file Language.php.

References $s, and array().

Referenced by sprintfDate(), and LanguageTest\testRomanNumerals().

◆ segmentByWord()

Language::segmentByWord (   $string)

Some languages such as Chinese require word segmentation, Specify such segmentation when overridden in derived class.

Parameters
$stringString
Returns
String

Reimplemented in LanguageZh_hans, LanguageYue, and LanguageJa.

Definition at line 2659 of file Language.php.

◆ segmentForDiff()

Language::segmentForDiff (   $text)

languages like Chinese need to be segmented in order for the diff to be of any use

Parameters
$textString
Returns
String

Reimplemented in LanguageZh.

Definition at line 3751 of file Language.php.

◆ semicolonList()

Language::semicolonList ( array  $list)

Take a list of strings and build a locale-friendly semicolon-separated list, using the local semicolon-separator message.

Parameters
$listarray of strings to put in a semicolon list
Returns
string

Definition at line 3272 of file Language.php.

References wfMessage().

◆ separatorTransformTable()

Language::separatorTransformTable ( )
Returns
array

Definition at line 3217 of file Language.php.

Referenced by formatNum(), and parseFormattedNumber().

◆ setCode()

Language::setCode (   $code)
Parameters
$codestring

Definition at line 4041 of file Language.php.

Referenced by newFromCode().

◆ setNamespaces()

Language::setNamespaces ( array  $namespaces)

Arbitrarily set all of the namespace names at once.

Mainly used for testing

Parameters
$namespacesArray of namespaces (id => name)

Definition at line 548 of file Language.php.

References $namespaces.

◆ specialList()

Language::specialList (   $page,
  $details,
  $oppositedm = true 
)

Make a list item, used by various special pages.

Parameters
$pageString Page link
$detailsString Text between brackets
$oppositedmBoolean Add the direction mark opposite to your language, to display text properly
Returns
String

Definition at line 4469 of file Language.php.

References getDirMark(), getMessageFromDB(), and wfMessage().

◆ specialPage()

Language::specialPage (   $name)
Parameters
$namestring
Returns
string

Definition at line 772 of file Language.php.

◆ sprintfDate()

Language::sprintfDate (   $format,
  $ts,
DateTimeZone  $zone = null 
)

This is a workalike of PHP's date() function, but with better internationalisation, a reduced set of format characters, and a better escaping format.

Supported format characters are dDjlNwzWFmMntLoYyaAgGhHiscrUeIOPTZ. See the PHP manual for definitions. There are a number of extensions, which start with "x":

xn Do not translate digits of the next numeric format character xN Toggle raw digit (xn) flag, stays set until explicitly unset xr Use roman numerals for the next numeric format character xh Use hebrew numerals for the next numeric format character xx Literal x xg Genitive month name

xij j (day number) in Iranian calendar xiF F (month name) in Iranian calendar xin n (month number) in Iranian calendar xiy y (two digit year) in Iranian calendar xiY Y (full year) in Iranian calendar

xjj j (day number) in Hebrew calendar xjF F (month name) in Hebrew calendar xjt t (days in month) in Hebrew calendar xjx xg (genitive month name) in Hebrew calendar xjn n (month number) in Hebrew calendar xjY Y (full year) in Hebrew calendar

xmj j (day number) in Hijri calendar xmF F (month name) in Hijri calendar xmn n (month number) in Hijri calendar xmY Y (full year) in Hijri calendar

xkY Y (full year) in Thai solar calendar. Months and days are identical to the Gregorian calendar xoY Y (full year) in Minguo calendar or Juche year. Months and days are identical to the Gregorian calendar xtY Y (full year) in Japanese nengo. Months and days are identical to the Gregorian calendar

Characters enclosed in double quotes will be considered literal (with the quotes themselves removed). Unmatched quotes will be considered literal quotes. Example:

"The month is" F => The month is January i's" => 20'11"

Backslash escaping is also supported.

Input timestamp is assumed to be pre-normalized to the desired local time zone, if any. Note that the format characters crUeIOPTZ will assume $ts is UTC if $zone is not given.

Parameters
$formatString
$tsString: 14-character timestamp YYYYMMDDHHMMSS 01234567890123
$zoneDateTimeZone: Timezone of $ts
Todo:
handling of "o" format character for Iranian, Hebrew, Hijri & Thai?
Exceptions
MWException
Returns
string

Definition at line 1122 of file Language.php.

References $s, formatNum(), getHebrewCalendarMonthName(), getHebrewCalendarMonthNameGen(), getHijriCalendarMonthName(), getIranianCalendarMonthName(), getMonthAbbreviation(), getMonthName(), getMonthNameGen(), getWeekdayAbbreviation(), getWeekdayName(), hebrewNumeral(), romanNumeral(), tsToHebrew(), tsToHijri(), tsToIranian(), and tsToYear().

Referenced by date(), getHumanTimestamp(), internalUserTimeAndDate(), time(), and timeanddate().

◆ time()

Language::time (   $ts,
  $adj = false,
  $format = true,
  $timecorrection = false 
)
Parameters
$tsMixed: the time format which needs to be turned into a date('YmdHis') format with wfTimestamp(TS_MW,$ts)
$adjBool: whether to adjust the time output according to the user configured offset ($timecorrection)
$formatMixed: true to use user's date format preference
$timecorrectionString|bool the time offset as returned by validateTimeZone() in Special:Preferences
Returns
string

Definition at line 2064 of file Language.php.

References dateFormat(), getDateFormatString(), sprintfDate(), TS_MW, userAdjust(), and wfTimestamp().

Referenced by LanguageWa\timeanddate().

◆ timeanddate()

Language::timeanddate (   $ts,
  $adj = false,
  $format = true,
  $timecorrection = false 
)
Parameters
$tsMixed: the time format which needs to be turned into a date('YmdHis') format with wfTimestamp(TS_MW,$ts)
$adjBool: whether to adjust the time output according to the user configured offset ($timecorrection)
$formatMixed: what format to return, if it's false output the default one (default true)
$timecorrectionString|bool the time offset as returned by validateTimeZone() in Special:Preferences
Returns
string

Reimplemented in LanguageWa.

Definition at line 2084 of file Language.php.

References dateFormat(), getDateFormatString(), sprintfDate(), TS_MW, userAdjust(), and wfTimestamp().

Referenced by formatExpiry(), and translateBlockExpiry().

◆ transformUsingPairFile()

Language::transformUsingPairFile (   $file,
  $string 
)

Transform a string using serialized data stored in the given file (which must be in the serialized subdirectory of $IP).

The file contains pairs mapping source characters to destination characters.

The data is cached in process memory. This will go faster if you have the FastStringSearch extension.

Parameters
$filestring
$stringstring
Exceptions
MWException
Returns
string

Definition at line 2854 of file Language.php.

References $file, and wfGetPrecompiledData().

Referenced by LanguageAr\normalize(), LanguageMl\normalize(), and normalize().

◆ translateBlockExpiry()

Language::translateBlockExpiry (   $str)
Todo:
Maybe translate block durations.

Note that this function is somewhat misnamed: it deals with translating the duration ("1 week", "4 days", etc), not the expiry time (which is an absolute timestamp). Please note: do NOT add this blindly, as it is used on old expiry lengths recorded in log entries. You'd need to provide the start date to match up with it.

Parameters
$strString: the validated block duration in English
Returns
string Somehow translated block duration
See also
LanguageFi.php for example implementation

Definition at line 3707 of file Language.php.

References $time, $value, array(), as, formatDuration(), SpecialBlock\getSuggestedDurations(), and timeanddate().

◆ truncate()

Language::truncate (   $string,
  $length,
  $ellipsis = '...',
  $adjustLength = true 
)

Truncate a string to a specified length in bytes, appending an optional string (e.g.

for ellipses)

The database offers limited byte lengths for some columns in the database; multi-byte character sets mean we need to ensure that only whole characters are included, otherwise broken characters can be passed to the user

If $length is negative, the string will be truncated from the beginning

Parameters
$stringString to truncate
$lengthInt: maximum length (including ellipses)
$ellipsisString to append to the truncated text
$adjustLengthBoolean: Subtract length of ellipsis from $length. $adjustLength was introduced in 1.18, before that behaved as if false.
Returns
string

Definition at line 3308 of file Language.php.

References removeBadCharFirst(), removeBadCharLast(), and wfMessage().

◆ truncate_endBracket()

Language::truncate_endBracket ( $tag,
  $tagType,
  $lastCh,
$openTags 
)
private

truncateHtml() helper function (a) push or pop $tag from $openTags as needed (b) clear $tag value

Parameters
&$tagstring Current HTML tag name we are looking at
$tagTypeint (0-open tag, 1-close tag)
$lastChstring Character before the '>' that ended this tag
&$openTagsarray Open tag stack (not accounting for $tag)

Definition at line 3549 of file Language.php.

Referenced by truncateHtml().

◆ truncate_skip()

Language::truncate_skip ( $ret,
  $text,
  $search,
  $start,
  $len = null 
)
private

truncateHtml() helper function like strcspn() but adds the skipped chars to $ret

Parameters
$ret
$text
$search
$start
$len
Returns
int

Definition at line 3526 of file Language.php.

References $ret.

Referenced by truncateHtml().

◆ truncateHtml()

Language::truncateHtml (   $text,
  $length,
  $ellipsis = '...' 
)

Truncate a string of valid HTML to a specified length in bytes, appending an optional string (e.g.

for ellipses), and return valid HTML

This is only intended for styled/linked text, such as HTML with tags like and , were the tags are self-contained (valid HTML). Also, this will not detect things like "display:none" CSS.

Note: since 1.18 you do not need to leave extra room in $length for ellipses.

Parameters
string$textHTML string to truncate
int$length(zero/positive) Maximum length (including ellipses)
string$ellipsisString to append to the truncated text
Returns
string

Definition at line 3408 of file Language.php.

References $ret, array(), list, removeBadCharLast(), truncate_endBracket(), truncate_skip(), and wfMessage().

◆ tsToHebrew()

static Language::tsToHebrew (   $ts)
staticprivate

Converting Gregorian dates to Hebrew dates.

Based on a JavaScript code by Abu Mami and Yisrael Hersch (abu-m.nosp@m.ami@.nosp@m.kalua.nosp@m.ch.n.nosp@m.et, http://www.kaluach.net), who permitted to translate the relevant functions into PHP and release them under GNU GPL.

The months are counted from Tishrei = 1. In a leap year, Adar I is 13 and Adar II is 14. In a non-leap year, Adar is 6.

Parameters
$tsstring
Returns
string

Definition at line 1548 of file Language.php.

References array(), and hebrewYearStart().

Referenced by sprintfDate().

◆ tsToHijri()

static Language::tsToHijri (   $ts)
staticprivate

Converting Gregorian dates to Hijri dates.

Based on a PHP-Nuke block by Sharjeel which is released under GNU/GPL license

See also
http://phpnuke.org/modules.php?name=News&file=article&sid=8234&mode=thread&order=0&thold=0
Parameters
$tsstring
Returns
string

Definition at line 1498 of file Language.php.

References array().

Referenced by sprintfDate().

◆ tsToIranian()

static Language::tsToIranian (   $ts)
staticprivate

Algorithm by Roozbeh Pournader and Mohammad Toossi to convert Gregorian dates to Iranian dates.

Originally written in C, it is released under the terms of GNU Lesser General Public License. Conversion to PHP was performed by Niklas Laxström.

Link: http://www.farsiweb.info/jalali/jalali.c

Parameters
$tsstring
Returns
string

Definition at line 1440 of file Language.php.

References array().

Referenced by sprintfDate().

◆ tsToYear()

static Language::tsToYear (   $ts,
  $cName 
)
staticprivate

Algorithm to convert Gregorian dates to Thai solar dates, Minguo dates or Minguo dates.

Link: http://en.wikipedia.org/wiki/Thai_solar_calendar http://en.wikipedia.org/wiki/Minguo_calendar http://en.wikipedia.org/wiki/Japanese_era_name

Parameters
$tsString: 14-character timestamp
$cNameString: calender name
Returns
Array: converted year, month, day

Definition at line 1727 of file Language.php.

References array().

Referenced by sprintfDate().

◆ uc()

Language::uc (   $str,
  $first = false 
)

Convert a string to uppercase.

Parameters
$strstring
$firstbool
Returns
string

Definition at line 2450 of file Language.php.

References array(), isMultibyte(), and ucfirst().

Referenced by caseFold(), and ucfirst().

◆ ucCallback()

Language::ucCallback (   $matches)
Parameters
$matchesarray
Returns
string

Definition at line 2392 of file Language.php.

References $matches, getCaseMaps(), and list.

◆ ucfirst()

Language::ucfirst (   $str)

Make a string's first character uppercase.

Parameters
$strstring
Returns
string

Reimplemented in LanguageKk, LanguageKaa, LanguageTr, and LanguageAz.

Definition at line 2430 of file Language.php.

References uc().

Referenced by classFromCode(), getFileName(), uc(), and ucwordbreaksCallbackAscii().

◆ ucwordbreaks()

Language::ucwordbreaks (   $str)

capitalize words at word breaks

Parameters
$strstring
Returns
mixed

Definition at line 2567 of file Language.php.

References array(), isMultibyte(), and lc().

◆ ucwordbreaksCallbackAscii()

Language::ucwordbreaksCallbackAscii (   $matches)
Parameters
$matchesarray
Returns
mixed|string

Definition at line 2376 of file Language.php.

References $matches, and ucfirst().

◆ ucwordbreaksCallbackMB()

Language::ucwordbreaksCallbackMB (   $matches)
Parameters
$matchesarray
Returns
string

Definition at line 2384 of file Language.php.

References $matches.

◆ ucwords()

Language::ucwords (   $str)
Parameters
$strstring
Returns
mixed|string

Definition at line 2535 of file Language.php.

References array(), isMultibyte(), and lc().

◆ ucwordsCallbackMB()

Language::ucwordsCallbackMB (   $matches)
Parameters
$matchesarray
Returns
string

Definition at line 2410 of file Language.php.

References $matches.

◆ ucwordsCallbackWiki()

Language::ucwordsCallbackWiki (   $matches)
Parameters
$matchesarray
Returns
string

Definition at line 2418 of file Language.php.

References $matches, getCaseMaps(), and list.

◆ unsegmentForDiff()

Language::unsegmentForDiff (   $text)

and unsegment to show the result

Parameters
$textString
Returns
String

Reimplemented in LanguageZh.

Definition at line 3761 of file Language.php.

◆ userAdjust()

Language::userAdjust (   $ts,
  $tz = false 
)

Used by date() and time() to adjust the time output.

Parameters
$tsInt the time in date('YmdHis') format
$tzMixed: adjust the time by this amount (default false, mean we get user timecorrection setting)
Returns
int

Definition at line 1898 of file Language.php.

References $t, $wgUser, date(), global, wfRestoreWarnings(), and wfSuppressWarnings().

Referenced by LanguageWa\date(), date(), internalUserTimeAndDate(), time(), LanguageWa\timeanddate(), and timeanddate().

◆ userDate()

Language::userDate (   $ts,
User  $user,
array  $options = array() 
)

Get the formatted date for the given timestamp and formatted for the given user.

Parameters
$tsMixed: the time format which needs to be turned into a date('YmdHis') format with wfTimestamp(TS_MW,$ts)
$userUser object used to get preferences for timezone and format
$optionsArray, can contain the following keys:
  • 'timecorrection': time correction, can have the following values:
    • true: use user's preference
    • false: don't use time correction
    • integer: value of time correction in minutes
  • 'format': format to use, can have the following values:
    • true: use user's preference
    • false: use default preference
    • string: format to use
Since
1.19
Returns
String

Definition at line 2210 of file Language.php.

References $options, $user, and internalUserTimeAndDate().

◆ userTime()

Language::userTime (   $ts,
User  $user,
array  $options = array() 
)

Get the formatted time for the given timestamp and formatted for the given user.

Parameters
$tsMixed: the time format which needs to be turned into a date('YmdHis') format with wfTimestamp(TS_MW,$ts)
$userUser object used to get preferences for timezone and format
$optionsArray, can contain the following keys:
  • 'timecorrection': time correction, can have the following values:
    • true: use user's preference
    • false: don't use time correction
    • integer: value of time correction in minutes
  • 'format': format to use, can have the following values:
    • true: use user's preference
    • false: use default preference
    • string: format to use
Since
1.19
Returns
String

Definition at line 2233 of file Language.php.

References $options, $user, and internalUserTimeAndDate().

◆ userTimeAndDate()

Language::userTimeAndDate (   $ts,
User  $user,
array  $options = array() 
)

Get the formatted date and time for the given timestamp and formatted for the given user.

Parameters
$tsMixed: the time format which needs to be turned into a date('YmdHis') format with wfTimestamp(TS_MW,$ts)
$userUser object used to get preferences for timezone and format
$optionsArray, can contain the following keys:
  • 'timecorrection': time correction, can have the following values:
    • true: use user's preference
    • false: don't use time correction
    • integer: value of time correction in minutes
  • 'format': format to use, can have the following values:
    • true: use user's preference
    • false: use default preference
    • string: format to use
Since
1.19
Returns
String

Definition at line 2256 of file Language.php.

References $options, $user, and internalUserTimeAndDate().

◆ viewPrevNext()

Language::viewPrevNext ( Title  $title,
  $offset,
  $limit,
array  $query = array(),
  $atend = false 
)

Generate (prev x| next x) (20|50|100...) type links for paging.

Parameters
$titleTitle object to link
$offsetInteger offset parameter
$limitInteger limit parameter
$queryarray|String optional URL query parameter string
$atendBool optional param for specified if this is the last page
Returns
String

Definition at line 4487 of file Language.php.

References $limit, $query, $title, array(), as, formatNum(), numLink(), pipeList(), and wfMessage().

Member Data Documentation

◆ $dataCache

Language::$dataCache
static

Definition at line 97 of file Language.php.

Referenced by getLocalisationCache().

◆ $dateFormatStrings

Language::$dateFormatStrings = array()

Definition at line 84 of file Language.php.

◆ $durationIntervals

Language::$durationIntervals
static
Initial value:
'millennia' => 31556952000,
'centuries' => 3155695200,
'decades' => 315569520,
'years' => 31556952,
'weeks' => 604800,
'days' => 86400,
'hours' => 3600,
'minutes' => 60,
'seconds' => 1,
)

Definition at line 159 of file Language.php.

◆ $fallbackLanguageCache

Language::$fallbackLanguageCache = array()
staticprivate

Definition at line 177 of file Language.php.

◆ $GREG_DAYS

Language::$GREG_DAYS = array( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 )
staticprivate

Definition at line 1425 of file Language.php.

◆ $IRANIAN_DAYS

Language::$IRANIAN_DAYS = array( 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29 )
staticprivate

Definition at line 1426 of file Language.php.

◆ $mCode

Language::$mCode

Definition at line 80 of file Language.php.

Referenced by getCode().

◆ $mConverter

◆ $mExtendedSpecialPageAliases

Language::$mExtendedSpecialPageAliases

Definition at line 85 of file Language.php.

Referenced by getSpecialPageAliases().

◆ $mHebrewCalendarMonthGenMsgs

Language::$mHebrewCalendarMonthGenMsgs
static
Initial value:
'hebrew-calendar-m1-gen', 'hebrew-calendar-m2-gen', 'hebrew-calendar-m3-gen',
'hebrew-calendar-m4-gen', 'hebrew-calendar-m5-gen', 'hebrew-calendar-m6-gen',
'hebrew-calendar-m7-gen', 'hebrew-calendar-m8-gen', 'hebrew-calendar-m9-gen',
'hebrew-calendar-m10-gen', 'hebrew-calendar-m11-gen', 'hebrew-calendar-m12-gen',
'hebrew-calendar-m6a-gen', 'hebrew-calendar-m6b-gen'
)

Definition at line 140 of file Language.php.

◆ $mHebrewCalendarMonthMsgs

Language::$mHebrewCalendarMonthMsgs
static
Initial value:
'hebrew-calendar-m1', 'hebrew-calendar-m2', 'hebrew-calendar-m3',
'hebrew-calendar-m4', 'hebrew-calendar-m5', 'hebrew-calendar-m6',
'hebrew-calendar-m7', 'hebrew-calendar-m8', 'hebrew-calendar-m9',
'hebrew-calendar-m10', 'hebrew-calendar-m11', 'hebrew-calendar-m12',
'hebrew-calendar-m6a', 'hebrew-calendar-m6b'
)

Definition at line 132 of file Language.php.

◆ $mHijriCalendarMonthMsgs

Language::$mHijriCalendarMonthMsgs
static
Initial value:
'hijri-calendar-m1', 'hijri-calendar-m2', 'hijri-calendar-m3',
'hijri-calendar-m4', 'hijri-calendar-m5', 'hijri-calendar-m6',
'hijri-calendar-m7', 'hijri-calendar-m8', 'hijri-calendar-m9',
'hijri-calendar-m10', 'hijri-calendar-m11', 'hijri-calendar-m12'
)

Definition at line 148 of file Language.php.

◆ $mHtmlCode

Language::$mHtmlCode = null
private

Definition at line 82 of file Language.php.

Referenced by getHtmlCode().

◆ $mIranianCalendarMonthMsgs

Language::$mIranianCalendarMonthMsgs
static
Initial value:
'iranian-calendar-m1', 'iranian-calendar-m2', 'iranian-calendar-m3',
'iranian-calendar-m4', 'iranian-calendar-m5', 'iranian-calendar-m6',
'iranian-calendar-m7', 'iranian-calendar-m8', 'iranian-calendar-m9',
'iranian-calendar-m10', 'iranian-calendar-m11', 'iranian-calendar-m12'
)

Definition at line 125 of file Language.php.

◆ $mLangObjCache

Language::$mLangObjCache = array()
static

Definition at line 99 of file Language.php.

◆ $mLoaded

Language::$mLoaded = false

Definition at line 80 of file Language.php.

◆ $mMagicExtensions

Language::$mMagicExtensions = array()

Definition at line 81 of file Language.php.

Referenced by addMagicWordsByLang().

◆ $mMagicHookDone

Language::$mMagicHookDone = false

Definition at line 81 of file Language.php.

◆ $mMonthAbbrevMsgs

Language::$mMonthAbbrevMsgs
static
Initial value:
'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug',
'sep', 'oct', 'nov', 'dec'
)

Definition at line 120 of file Language.php.

◆ $mMonthGenMsgs

Language::$mMonthGenMsgs
static
Initial value:
'january-gen', 'february-gen', 'march-gen', 'april-gen', 'may-gen', 'june-gen',
'july-gen', 'august-gen', 'september-gen', 'october-gen', 'november-gen',
'december-gen'
)

Definition at line 115 of file Language.php.

◆ $mMonthMsgs

Language::$mMonthMsgs
static
Initial value:
'january', 'february', 'march', 'april', 'may_long', 'june',
'july', 'august', 'september', 'october', 'november',
'december'
)

Definition at line 110 of file Language.php.

◆ $mNamespaceIds

Language::$mNamespaceIds

Definition at line 87 of file Language.php.

Referenced by getNamespaceIds().

◆ $mParentLanguage

Language::$mParentLanguage = false

Definition at line 82 of file Language.php.

Referenced by getParentLanguage().

◆ $mVariants

Language::$mVariants

Definition at line 80 of file Language.php.

◆ $mWeekdayAbbrevMsgs

Language::$mWeekdayAbbrevMsgs
static
Initial value:
'sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'
)

Definition at line 106 of file Language.php.

◆ $mWeekdayMsgs

Language::$mWeekdayMsgs
static
Initial value:
'sunday', 'monday', 'tuesday', 'wednesday', 'thursday',
'friday', 'saturday'
)

Definition at line 101 of file Language.php.

◆ $namespaceAliases

Language::$namespaceAliases

Definition at line 87 of file Language.php.

Referenced by getNamespaceAliases().

◆ $namespaceNames

Language::$namespaceNames
protected

Definition at line 87 of file Language.php.

Referenced by getNamespaces().

◆ $transformData

Language::$transformData = array()

ReplacementArray object caches.

Definition at line 92 of file Language.php.


The documentation for this class was generated from the following file:
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.