|
MediaWiki master
|
Base class for language-specific code. More...
Inherits Bcp47Code.
Inherited by MediaWiki\Languages\LanguageAr, MediaWiki\Languages\LanguageAz, MediaWiki\Languages\LanguageBe_tarask, MediaWiki\Languages\LanguageBs, MediaWiki\Languages\LanguageCu, MediaWiki\Languages\LanguageDsb, MediaWiki\Languages\LanguageEn, MediaWiki\Languages\LanguageFi, MediaWiki\Languages\LanguageGa, MediaWiki\Languages\LanguageHsb, MediaWiki\Languages\LanguageHu, MediaWiki\Languages\LanguageHy, MediaWiki\Languages\LanguageJa, MediaWiki\Languages\LanguageKaa, MediaWiki\Languages\LanguageKk_cyrl, MediaWiki\Languages\LanguageKm, MediaWiki\Languages\LanguageKsh, MediaWiki\Languages\LanguageLa, MediaWiki\Languages\LanguageMl, MediaWiki\Languages\LanguageMy, MediaWiki\Languages\LanguageOs, MediaWiki\Languages\LanguageQqx, MediaWiki\Languages\LanguageSh, MediaWiki\Languages\LanguageSl, MediaWiki\Languages\LanguageTr, MediaWiki\Languages\LanguageTyv, MediaWiki\Languages\LanguageWa, MediaWiki\Languages\LanguageYue, and MediaWiki\Languages\LanguageZh_hans.

Public Member Functions | |
| __construct (string $code, NamespaceInfo $namespaceInfo, LocalisationCache $localisationCache, LanguageNameUtils $langNameUtils, LanguageFallback $langFallback, LanguageConverterFactory $converterFactory, HookContainer $hookContainer, Config $config) | |
| alignEnd () | |
| Return 'right' or 'left' as appropriate alignment for line-end for this language's text direction. | |
| alignStart () | |
| Return 'left' or 'right' as appropriate alignment for line-start for this language's text direction. | |
| caseFold ( $s) | |
| Return a case-folded representation of $s. | |
| checkTitleEncoding (string $s) | |
| commaList (array $list) | |
| Take a list of strings and build a locale-friendly comma-separated list, using the local comma-separator message. | |
| convertForSearchResult ( $termsArray) | |
| convertGrammar ( $word, $case) | |
| Grammatical transformations, needed for inflected languages Invoked by putting {{grammar:case|word}} in a message. | |
| convertPlural ( $count, $forms) | |
| Plural form transformations, needed for some languages. | |
| 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. | |
| digitGroupingPattern () | |
| digitTransformTable () | |
| embedBidi ( $text='') | |
| Wraps argument with unicode control characters for directionality safety. | |
| emphasize ( $text) | |
| Italic is unsuitable for some languages. | |
| equals (Language $lang) | |
| Compare with another language object. | |
| fallback8bitEncoding () | |
| firstChar ( $s) | |
| Get the first character of a string. | |
| formatBitrate ( $bps) | |
| Format a bitrate for output, using an appropriate unit (bps, kbps, Mbps, Gbps, Tbps, Pbps, Ebps, Zbps, Ybps, Rbps or Qbps) according to the magnitude in question. | |
| formatComputingNumbers ( $size, $boundary, $messageKey) | |
| formatDuration ( $seconds, array $chosenIntervals=[]) | |
| Takes a number of seconds and turns it into a text using values such as hours and minutes. | |
| formatDurationBetweenTimestamps (int $timestamp1, int $timestamp2, ?int $precision=null) | |
| Takes two timestamps and turns the difference between them into a text using values such as hours and minutes. | |
| formatExpiry ( $expiry, $format=true, $infinity='infinity', $user=null) | |
| Decode an expiry (block, protection, etc.) which has come from the DB. | |
| formatNum ( $number) | |
| Normally we output all numbers in plain en_US style, that is 293,291.235 for two hundred ninety-three thousand two hundred ninety-one point two hundred thirty-five. | |
| formatNumNoSeparators ( $number) | |
| Front-end for non-commafied formatNum. | |
| formatSize ( $size) | |
| Format a size in bytes for output, using an appropriate unit (B, KB, MB, GB, TB, PB, EB, ZB, YB, RB or QB) according to the magnitude in question. | |
| formatTimePeriod ( $seconds, $format=[]) | |
| Formats a time given in seconds into a string representation of that time. | |
| gender ( $gender, $forms) | |
| Provides an alternative text depending on specified gender. | |
| getAllMessages () | |
| getArrow ( $direction='forwards') | |
| An arrow, depending on the language direction. | |
| getBlockDurations ( $includeOther=true) | |
| Get an array of suggested block durations from MediaWiki:Ipboptions. | |
| getBookstoreList () | |
| Exports $wgBookstoreListEn. | |
| getCode () | |
| Get the internal language code for this language object. | |
| getCompiledPluralRules () | |
| Get the compiled plural rules for the language. | |
| getDateFormats () | |
| getDateFormatString ( $type, $pref) | |
| Get a format string for a given type and preference. | |
| getDatePreferenceMigrationMap () | |
| getDatePreferences () | |
| getDefaultDateFormat () | |
| getDir () | |
| Return the correct HTML 'dir' attribute value for this language. | |
| getDirMark ( $opposite=false) | |
| A hidden direction mark (LRM or RLM), depending on the language direction. | |
| getDirMarkEntity ( $opposite=false) | |
| A hidden direction mark (LRM or RLM), depending on the language direction. | |
| getDurationIntervals ( $seconds, array $chosenIntervals=[]) | |
| Takes a number of seconds and returns an array with a set of corresponding intervals. | |
| getFallbackLanguages () | |
| getFormalityIndex () | |
| Some languages provide translations in different levels of formality (or manner of address), for example using the T-V distinction. | |
| getFormattedNamespaces () | |
| A convenience function that returns {. | |
| getFormattedNsText ( $index) | |
| A convenience function that returns the same thing as getNsText() except with '_' changed to ' ', useful for producing output. | |
| getGenderNsText ( $index, $gender) | |
| Returns gender-dependent namespace alias if available. | |
| getGrammarForms () | |
| Get the grammar forms for the content language. | |
| getGrammarTransformations () | |
| Get the grammar transformations data for the language. | |
| getGroupMemberName (string $group, $member) | |
| Gets the localized name for a member of a user group if it exists. | |
| getGroupName ( $group) | |
| Gets the localized friendly name for a group, if it exists. | |
| getHtmlCode () | |
| Get the code in BCP 47 format which we can use inside html lang="" tags. | |
| getHumanTimestamp (MWTimestamp $time, ?MWTimestamp $relativeTo=null, ?UserIdentity $user=null) | |
| Get the timestamp in a human-friendly relative format, e.g., "3 days ago". | |
| getJsData () | |
| getJsDateFormats () | |
| getLocalNsIndex ( $text) | |
| Get a namespace key by case-insensitive value. | |
| getMagic ( $mw) | |
| Fill a MagicWord object with data from this instance. | |
| getMagicWords () | |
| Get all the magic words from the localisation cache. | |
| getMessage ( $key) | |
| getMessageFromDB ( $msg) | |
| Get a message from the MediaWiki namespace. | |
| getMonthAbbreviation ( $key) | |
| getMonthAbbreviationsArray () | |
| getMonthName ( $key) | |
| getMonthNameGen ( $key) | |
| getMonthNamesArray () | |
| getNamespaceAliases () | |
| getNamespaceIds () | |
| getNamespaces () | |
| Returns an array of localised namespaces (with underscores, without considering language variants) indexed by their numbers. | |
| getNsIndex ( $text) | |
| Get a namespace key by case-insensitive value. | |
| getNsText ( $index) | |
| Get a namespace value by key. | |
| getPluralRuleIndexNumber ( $number) | |
| Find the index number of the plural rule appropriate for the given number. | |
| getPluralRules () | |
| Get the plural rules for the language. | |
| getPluralRuleType ( $number) | |
| Find the plural rule type appropriate for the given number. | |
| getPluralRuleTypes () | |
| Get the plural rule types for the language. | |
| getSpecialPageAliases () | |
| Get special page names, as an associative array canonical name => array of valid names, including aliases. | |
| getVariantname ( $code, $usemsg=true) | |
| Short names for language variants used for language conversion links. | |
| getWeekdayAbbreviation ( $key) | |
| getWeekdayName ( $key) | |
| hasWordBreaks () | |
| Most writing systems use whitespace to break up words. | |
| iconv ( $in, $out, $string) | |
| isRTL () | |
| For right-to-left language support. | |
| isSameCodeAs (Bcp47Code $other) | |
| Compare this Language object to a Bcp47Code. | |
| lc ( $str, $first=false) | |
| 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]]. | |
| linkPrefixExtension () | |
| To allow "foo[[bar]]" to extend the link over the whole word "foobar". | |
| linkTrail () | |
| A regular expression to match legal word-trailing characters which should be merged onto a link of the form [[foo]]bar. | |
| listToText (array $list) | |
| Take a list of strings and build a locale-friendly comma-separated list, using the local comma-separator message. | |
| minimumGroupingDigits () | |
| The minimum number of digits a number must have, in addition to the grouping size, before grouping separators are added. | |
| needsGenderDistinction () | |
| Whether this language uses gender-dependent namespace aliases. | |
| normalize ( $s) | |
| Convert a UTF-8 string to normal form C. | |
| normalizeForSearch ( $text) | |
| Some languages have special punctuation need to be normalized. | |
| parseFormattedNumber ( $number) | |
| pipeList (array $list) | |
| Same as commaList, but separate it with the pipe instead. | |
| resetNamespaces () | |
| Resets all the namespace caches. | |
| segmentByWord ( $string) | |
| Some languages such as Chinese require word segmentation, Specify such segmentation when overridden in derived class. | |
| segmentForDiff ( $text) | |
| Languages like Chinese need to be segmented in order for the diff to be of any use. | |
| semicolonList (array $list) | |
| Take a list of strings and build a locale-friendly semicolon-separated list, using the local semicolon-separator message. | |
| separatorTransformTable () | |
| setNamespaces (array $namespaces) | |
| Arbitrarily set all the namespace names at once. | |
| specialList ( $page, $details) | |
| Make a list item, used by various special pages. | |
| sprintfDate ( $format, $ts, ?DateTimeZone $zone=null, &$ttl='unused') | |
| This is a workalike of PHP's date() function, but with better internationalisation, a reduced set of format characters, and a better escaping format. | |
| time ( $ts, $adj=false, $format=true, $timecorrection=false) | |
| timeanddate ( $ts, $adj=false, $format=true, $timecorrection=false) | |
| toBcp47Code () | |
| Implement the Bcp47Code interface. | |
| translateBlockExpiry ( $str, ?UserIdentity $user=null, $now=0) | |
| truncateForDatabase ( $string, $length, $ellipsis='...', $adjustLength=true) | |
| Truncate a string to a specified length in bytes, appending an optional string (e.g., for ellipsis) When an ellipsis isn't needed, using mb_strcut() directly is recommended. | |
| truncateForVisual ( $string, $length, $ellipsis='...', $adjustLength=true) | |
| Truncate a string to a specified number of characters, appending an optional string (e.g., for ellipsis). | |
| 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. | |
| uc ( $str, $first=false) | |
| ucfirst ( $str) | |
| ucwordbreaks ( $str) | |
| capitalize words at word breaks | |
| ucwords ( $str) | |
| unsegmentForDiff ( $text) | |
| And unsegment to show the result. | |
| userAdjust ( $ts, $tz=false) | |
| Used by date() and time() to adjust the time output. | |
| userDate ( $ts, UserIdentity $user, array $options=[]) | |
| Get the formatted date for the given timestamp and formatted for the given user. | |
| userTime ( $ts, UserIdentity $user, array $options=[]) | |
| Get the formatted time for the given timestamp and formatted for the given user. | |
| userTimeAndDate ( $ts, UserIdentity $user, array $options=[]) | |
| Get the formatted date and time for the given timestamp and formatted for the given user. | |
Static Public Member Functions | |
| static | computeUnitTimestampDeadline (DateTimeInterface $date, string $unit) |
| Compute a cache expiry to account for a dynamic timestamp displayed in output. | |
| static | getCodeFromFileName ( $filename, $prefix='Language', $suffix='.php') |
| Get the language code from a file name. | |
| static | hebrewNumeral ( $num) |
| Hebrew Gematria number formatting up to 9999. | |
| static | romanNumeral ( $num) |
| Roman number formatting up to 10000. | |
Public Attributes | |
| string[][] | $dateFormatStrings = [] |
| memoize | |
| string | $mCode |
| string[][] null | $mExtendedSpecialPageAliases |
| memoize | |
| $mMagicExtensions = [] | |
| const | HEBREW_CALENDAR_MONTH_GENITIVE_MESSAGES |
| const | HEBREW_CALENDAR_MONTHS_MESSAGES |
| const | HIJRI_CALENDAR_MONTH_MESSAGES |
| const | IRANIAN_CALENDAR_MONTHS_MESSAGES |
| const | MONTH_ABBREVIATED_MESSAGES |
| const | MONTH_GENITIVE_MESSAGES |
| const | MONTH_MESSAGES |
| const | WEEKDAY_ABBREVIATED_MESSAGES |
| const | WEEKDAY_MESSAGES |
Static Public Attributes | |
| static int[] | $durationIntervals = self::DURATION_INTERVALS |
| static | $mMonthAbbrevMsgs = self::MONTH_ABBREVIATED_MESSAGES |
| static | $mMonthMsgs = self::MONTH_MESSAGES |
Protected Member Functions | |
| getConverterInternal () | |
| Return the LanguageConverter for this language, convenience function for use in the language classes only. | |
| getHookContainer () | |
| Get a HookContainer, for hook metadata and running extension hooks. | |
| getHookRunner () | |
| Get a HookRunner, for running core hooks. | |
| getSearchIndexVariant () | |
| Specify the language variant that should be used for search indexing. | |
| handleExplicitPluralForms ( $count, array $forms) | |
| Handles explicit plural forms for Language::convertPlural() | |
| msg ( $msg,... $params) | |
| Gets the Message object from this language. | |
| preConvertPlural ($forms, $count) | |
| Checks that convertPlural was given an array and pads it to requested number of forms by copying the last one. | |
| removeBadCharLast ( $string) | |
| Remove bytes that represent an incomplete Unicode character at the end of string (e.g. | |
| transformUsingPairFile (string $dataClass, string $input) | |
| Transform a string using serialized data stored in the given file (which must be in the serialized subdirectory of $IP). | |
Static Protected Member Functions | |
| static | convertDoubleWidth ( $string) |
| Convert double-width roman characters to single-width. | |
| static | insertSpace ( $string, $pattern) |
Protected Attributes | |
| array< string, int > null | $mNamespaceIds |
| Indexed by localized lower-cased namespace name. | |
| array< string, int > null | $namespaceAliases |
| Map from alias to namespace ID. | |
| array< int, string > null | $namespaceNames |
| Indexed by numeric namespace ID. | |
| const | DURATION_INTERVALS |
Base class for language-specific code.
See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more information.
Definition at line 69 of file Language.php.
| MediaWiki\Language\Language::__construct | ( | string | $code, |
| NamespaceInfo | $namespaceInfo, | ||
| LocalisationCache | $localisationCache, | ||
| LanguageNameUtils | $langNameUtils, | ||
| LanguageFallback | $langFallback, | ||
| LanguageConverterFactory | $converterFactory, | ||
| HookContainer | $hookContainer, | ||
| Config | $config ) |
Definition at line 344 of file Language.php.
| MediaWiki\Language\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....
Definition at line 3384 of file Language.php.
| MediaWiki\Language\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....
Definition at line 3372 of file Language.php.
| MediaWiki\Language\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.
| string | $s |
Definition at line 3147 of file Language.php.
| MediaWiki\Language\Language::checkTitleEncoding | ( | string | $s | ) |
| MediaWiki\Language\Language::commaList | ( | array | $list | ) |
Take a list of strings and build a locale-friendly comma-separated list, using the local comma-separator message.
| string[] | $list | Array of strings to put in a comma list |
Definition at line 3781 of file Language.php.
Referenced by MediaWiki\Logging\BlockLogFormatter\formatBlockFlags(), and MediaWiki\Message\Message\listTypeMap().
|
static |
Compute a cache expiry to account for a dynamic timestamp displayed in output.
| DateTimeInterface | $date | Current timestamp with the display timezone |
| string | $unit | The unit the timestamp is expressed in; one of ("Y", "M", "W", "D", "H", "ISOY" or "AM") |
Definition at line 1409 of file Language.php.
|
staticprotected |
Convert double-width roman characters to single-width.
range: ff00-ff5f ~= 0020-007f
| string | $string |
Definition at line 3228 of file Language.php.
Referenced by MediaWiki\Languages\LanguageZh\convertForSearchResult().
| MediaWiki\Language\Language::convertForSearchResult | ( | $termsArray | ) |
| string[] | $termsArray |
Reimplemented in MediaWiki\Languages\LanguageZh.
Definition at line 3252 of file Language.php.
| MediaWiki\Language\Language::convertGrammar | ( | $word, | |
| $case ) |
Grammatical transformations, needed for inflected languages Invoked by putting {{grammar:case|word}} in a message.
| string | $word | |
| string | $case |
Reimplemented in MediaWiki\Languages\LanguageBs, MediaWiki\Languages\LanguageCu, MediaWiki\Languages\LanguageDsb, MediaWiki\Languages\LanguageFi, MediaWiki\Languages\LanguageGa, MediaWiki\Languages\LanguageHsb, MediaWiki\Languages\LanguageHu, MediaWiki\Languages\LanguageHy, MediaWiki\Languages\LanguageKaa, MediaWiki\Languages\LanguageKk, MediaWiki\Languages\LanguageKsh, MediaWiki\Languages\LanguageLa, MediaWiki\Languages\LanguageOs, MediaWiki\Languages\LanguageSh, MediaWiki\Languages\LanguageSl, and MediaWiki\Languages\LanguageTyv.
Definition at line 4139 of file Language.php.
References wfLogWarning().
| MediaWiki\Language\Language::convertPlural | ( | $count, | |
| $forms ) |
Plural form transformations, needed for some languages.
For example, there are 3 forms 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}}
| int | $count | Non-localized number |
| array | $forms | Different plural forms |
Reimplemented in MediaWiki\Languages\LanguageKsh.
Definition at line 4276 of file Language.php.
| MediaWiki\Language\Language::date | ( | $ts, | |
| $adj = false, | |||
| $format = true, | |||
| $timecorrection = false ) |
| string | $ts | The time format which needs to be turned into a date('YmdHis') format with wfTimestamp(TS::MW,$ts) |
| bool | $adj | Whether to adjust the time output according to the user configured offset ($timecorrection) |
| mixed | $format | True to use user's date format preference |
| string | false | $timecorrection | The time offset as returned by validateTimeZone() in Special:Preferences |
Reimplemented in MediaWiki\Languages\LanguageWa.
Definition at line 2485 of file Language.php.
References wfTimestamp().
Referenced by MediaWiki\Languages\LanguageFi\translateBlockExpiry().
| MediaWiki\Language\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);
[...]
}
| int | string | bool | $usePrefs | If true, the user's preference is used if false, the site/language default is used if int/string, assumed to be a format. |
Definition at line 2417 of file Language.php.
References MediaWiki\User\Options\UserOptionsLookup\getDefaultOption().
Referenced by MediaWiki\Languages\LanguageWa\date(), and MediaWiki\Languages\LanguageWa\timeanddate().
| MediaWiki\Language\Language::digitGroupingPattern | ( | ) |
Definition at line 3716 of file Language.php.
| MediaWiki\Language\Language::digitTransformTable | ( | ) |
Definition at line 3723 of file Language.php.
| MediaWiki\Language\Language::embedBidi | ( | $text = '' | ) |
Wraps argument with unicode control characters for directionality safety.
This solves the problem where directionality-neutral characters at the edge of the argument string get interpreted with the wrong directionality from the enclosing context, giving renderings that look corrupted like "(Ben_(WMF".
The wrapping is LRE...PDF or RLE...PDF, depending on the detected directionality of the argument string, using the BIDI algorithm's own "First strong directional codepoint" rule. Essentially, this works round the fact that there is no embedding equivalent of U+2068 FSI (isolation with heuristic direction inference). The latter is cleaner but still not widely supported.
Use of hidden control characters when the output allows use of HTML markup is discouraged and the recommendation is to use bdi HTML tag which doesn't have the issue of hidden characters ending up in user clipboard in text copy paste, see T375975.
| string | $text | Text to wrap |
Definition at line 4367 of file Language.php.
| MediaWiki\Language\Language::emphasize | ( | $text | ) |
Italic is unsuitable for some languages.
| string | $text | The text to be emphasized. |
Reimplemented in MediaWiki\Languages\LanguageJa.
Definition at line 3516 of file Language.php.
References wfDeprecated().
| MediaWiki\Language\Language::equals | ( | Language | $lang | ) |
Compare with another language object.
| Language | $lang |
Definition at line 4511 of file Language.php.
References MediaWiki\Language\Language\getCode().
| MediaWiki\Language\Language::fallback8bitEncoding | ( | ) |
Definition at line 3166 of file Language.php.
| MediaWiki\Language\Language::firstChar | ( | $s | ) |
Get the first character of a string.
| string | $s |
Definition at line 3264 of file Language.php.
| MediaWiki\Language\Language::formatBitrate | ( | $bps | ) |
Format a bitrate for output, using an appropriate unit (bps, kbps, Mbps, Gbps, Tbps, Pbps, Ebps, Zbps, Ybps, Rbps or Qbps) according to the magnitude in question.
This use base 1000. For base 1024 use formatSize(), for another base see formatComputingNumbers().
| int | $bps |
Definition at line 4763 of file Language.php.
| MediaWiki\Language\Language::formatComputingNumbers | ( | $size, | |
| $boundary, | |||
| $messageKey ) |
| int | $size | Size of the unit |
| int | $boundary | Size boundary (1000, or 1024 in most cases) |
| string | $messageKey | Message key to be used |
Definition at line 4776 of file Language.php.
| MediaWiki\Language\Language::formatDuration | ( | $seconds, | |
| array | $chosenIntervals = [] ) |
Takes a number of seconds and turns it into a text using values such as hours and minutes.
| int | $seconds | The number of seconds. |
| array | $chosenIntervals | The intervals to enable. |
Reimplemented in MediaWiki\Languages\LanguageZh_hans.
Definition at line 2543 of file Language.php.
| MediaWiki\Language\Language::formatDurationBetweenTimestamps | ( | int | $timestamp1, |
| int | $timestamp2, | ||
| ?int | $precision = null ) |
Takes two timestamps and turns the difference between them into a text using values such as hours and minutes.
| int | $timestamp1 | The first timestamp. |
| int | $timestamp2 | The second timestamp. |
| ?int | $precision | The number of intervals to show. |
Definition at line 2567 of file Language.php.
| MediaWiki\Language\Language::formatExpiry | ( | $expiry, | |
| $format = true, | |||
| $infinity = 'infinity', | |||
| $user = null ) |
Decode an expiry (block, protection, etc.) which has come from the DB.
| string | $expiry | Database expiry String |
| true | int | TS | $format | True to process using language functions, or TS:: constant to return the expiry in a given timestamp |
| string | $infinity | If $format is not true, use this string for infinite expiry |
| UserIdentity | null | $user | If $format is true, use this user for date format |
Definition at line 4626 of file Language.php.
References wfTimestamp().
Referenced by MediaWiki\Api\ApiBlockInfoHelper\getBlockDetails().
| MediaWiki\Language\Language::formatNum | ( | $number | ) |
Normally we output all numbers in plain en_US style, that is 293,291.235 for two hundred ninety-three thousand two hundred ninety-one point two hundred thirty-five.
However, this is not suitable for all languages, some such as Bengali (bn) 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.
| string | int | float | $number | Expected to be a pre-formatted (e.g. leading zeros, number of decimal places) numeric string. Any non-string will be cast to string. |
Reimplemented in MediaWiki\Languages\LanguageKm, and MediaWiki\Languages\LanguageMy.
Definition at line 3541 of file Language.php.
| MediaWiki\Language\Language::formatNumNoSeparators | ( | $number | ) |
Front-end for non-commafied formatNum.
| string | int | float | $number | The string to be formatted, should be an integer or a floating point number. |
Definition at line 3675 of file Language.php.
Referenced by MediaWiki\Languages\LanguageKm\formatNum(), and MediaWiki\Languages\LanguageMy\formatNum().
| MediaWiki\Language\Language::formatSize | ( | $size | ) |
Format a size in bytes for output, using an appropriate unit (B, KB, MB, GB, TB, PB, EB, ZB, YB, RB or QB) according to the magnitude in question.
This method use base 1024. For base 1000 use formatBitrate(), for another base see formatComputingNumbers()
| int | $size | Size to format |
Definition at line 4814 of file Language.php.
| MediaWiki\Language\Language::formatTimePeriod | ( | $seconds, | |
| $format = [] ) |
Formats a time given in seconds into a string representation of that time.
| int | float | $seconds | |
| array | $format | An optional argument that formats the returned string in different ways: If $format['avoid'] === 'avoidhours': don't show hours, just show days If $format['avoid'] === 'avoidseconds': don't show seconds if $seconds >= 1 hour, If $format['avoid'] === 'avoidminutes': don't show seconds/minutes if $seconds > 48 hours, If $format['noabbrevs'] is true: use 'seconds' and friends instead of 'seconds-abbrev' and friends. |
Definition at line 4660 of file Language.php.
| MediaWiki\Language\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 the current user is used, but only in (some) interface messages; otherwise the 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.
| string | $gender | |
| array | $forms |
Definition at line 4247 of file Language.php.
| MediaWiki\Language\Language::getAllMessages | ( | ) |
Definition at line 2953 of file Language.php.
| MediaWiki\Language\Language::getArrow | ( | $direction = 'forwards' | ) |
An arrow, depending on the language direction.
| string | $direction | The direction of the arrow: forwards (default), backwards, left, right, up, down. |
Definition at line 3444 of file Language.php.
| MediaWiki\Language\Language::getBlockDurations | ( | $includeOther = true | ) |
Get an array of suggested block durations from MediaWiki:Ipboptions.
| bool | $includeOther | Whether to include the 'other' option in the list of suggestions |
Definition at line 4390 of file Language.php.
| MediaWiki\Language\Language::getBookstoreList | ( | ) |
| MediaWiki\Language\Language::getCode | ( | ) |
Get the internal language code for this language object.
NOTE: The return value of this function is NOT HTML-safe and must be escaped with htmlspecialchars() or similar
Definition at line 4521 of file Language.php.
Referenced by MediaWiki\Skin\Components\SkinComponentLogo\__construct(), MediaWiki\Language\MessageCache\__construct(), MediaWiki\Message\Message\__serialize(), MediaWiki\Languages\LanguageHu\convertGrammar(), MediaWiki\Language\Language\equals(), MediaWiki\ChangeTags\ChangeTags\getChangeTagListSummary(), MediaWiki\Page\SitemapGenerator\getVariants(), and MediaWiki\Message\Message\inLanguage().
|
static |
Get the language code from a file name.
Inverse of getFileName()
| string | $filename | $prefix . $languageCode . $suffix |
| string | $prefix | Prefix before the language code |
| string | $suffix | Suffix after the language code |
Definition at line 4579 of file Language.php.
| MediaWiki\Language\Language::getCompiledPluralRules | ( | ) |
Get the compiled plural rules for the language.
Definition at line 4889 of file Language.php.
|
protected |
Return the LanguageConverter for this language, convenience function for use in the language classes only.
Definition at line 4981 of file Language.php.
Referenced by MediaWiki\Languages\LanguageZh\convertForSearchResult(), and MediaWiki\Language\Language\getNamespaceAliases().
| MediaWiki\Language\Language::getDateFormats | ( | ) |
Definition at line 682 of file Language.php.
| MediaWiki\Language\Language::getDateFormatString | ( | $type, | |
| $pref ) |
Get a format string for a given type and preference.
| string | $type | One of 'date', 'time', 'both', or 'pretty'. |
| string | $pref | The format name as it appears in Messages*.php under $datePreferences. |
Definition at line 2449 of file Language.php.
| MediaWiki\Language\Language::getDatePreferenceMigrationMap | ( | ) |
Definition at line 701 of file Language.php.
| MediaWiki\Language\Language::getDatePreferences | ( | ) |
Definition at line 675 of file Language.php.
| MediaWiki\Language\Language::getDefaultDateFormat | ( | ) |
Definition at line 689 of file Language.php.
Referenced by MediaWiki\ResourceLoader\DateFormatterConfig\getDataForLang().
| MediaWiki\Language\Language::getDir | ( | ) |
Return the correct HTML 'dir' attribute value for this language.
Definition at line 3360 of file Language.php.
Referenced by MediaWiki\RecentChanges\ChangesList\revDateLink().
| MediaWiki\Language\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.
Use of hidden control characters when the output allows use of HTML markup is discouraged and the recommendation is to use bdi HTML tag which doesn't have the issue of hidden characters ending up in user clipboard in text copy paste, see T375975.
| bool | $opposite | Get the direction mark opposite to your language |
Definition at line 3430 of file Language.php.
| MediaWiki\Language\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.
Use of hidden control characters when the output allows use of HTML markup is discouraged and the recommendation is to use bdi HTML tag which doesn't have the issue of hidden characters ending up in user clipboard in text copy paste, see T375975.
| bool | $opposite | Get the direction mark opposite to your language |
Definition at line 3406 of file Language.php.
References wfDeprecated().
| MediaWiki\Language\Language::getDurationIntervals | ( | $seconds, | |
| array | $chosenIntervals = [] ) |
Takes a number of seconds and returns an array with a set of corresponding intervals.
For example, 65 will be turned into [ minutes => 1, seconds => 5 ].
| int | $seconds | The number of seconds. |
| array | $chosenIntervals | The intervals to enable. |
Definition at line 2641 of file Language.php.
Referenced by MediaWiki\Languages\LanguageZh_hans\formatDuration().
| MediaWiki\Language\Language::getFallbackLanguages | ( | ) |
Definition at line 369 of file Language.php.
Referenced by MediaWiki\ResourceLoader\DateFormatterConfig\getDataForLang().
| MediaWiki\Language\Language::getFormalityIndex | ( | ) |
Some languages provide translations in different levels of formality (or manner of address), for example using the T-V distinction.
Since most translations do not differ by formality, we provide magic word, e.g. {{#FORMAL:Du|Sie}} that allows translating only once and defining different forms inline. This only works for languages that have a fallback relation. For example es and es-formal. The return value indicates which form of the forms given should be used for this language. Zero-based index.
Definition at line 4341 of file Language.php.
| MediaWiki\Language\Language::getFormattedNamespaces | ( | ) |
A convenience function that returns {.
NOTE: This is not suitable for UI text, as language variants of namespace names defined via system messages are ignored. Use {
Definition at line 455 of file Language.php.
References MediaWiki\Language\Language\getNamespaces().
| MediaWiki\Language\Language::getFormattedNsText | ( | $index | ) |
A convenience function that returns the same thing as getNsText() except with '_' changed to ' ', useful for producing output.
$mw_ns = $lang->getFormattedNsText( NS_MEDIAWIKI_TALK ); echo $mw_ns; // prints 'MediaWiki talk'
| int | $index | The array key of the namespace to return |
Definition at line 494 of file Language.php.
References MediaWiki\Language\Language\getNsText().
| MediaWiki\Language\Language::getGenderNsText | ( | $index, | |
| $gender ) |
Returns gender-dependent namespace alias if available.
See https://www.mediawiki.org/wiki/Manual:$wgExtraGenderNamespaces
| int | $index | Namespace index |
| string | $gender | Gender key (male, female... ) |
Definition at line 507 of file Language.php.
References MediaWiki\MainConfigNames\ExtraGenderNamespaces, and MediaWiki\Language\Language\getNsText().
| MediaWiki\Language\Language::getGrammarForms | ( | ) |
Get the grammar forms for the content language.
Definition at line 4191 of file Language.php.
| MediaWiki\Language\Language::getGrammarTransformations | ( | ) |
Get the grammar transformations data for the language.
Used like grammar forms, with {{GRAMMAR}} and cases, but uses pairs of regexes and replacements instead of code.
Definition at line 4210 of file Language.php.
References $IP.
| MediaWiki\Language\Language::getGroupMemberName | ( | string | $group, |
| $member ) |
Gets the localized name for a member of a user group if it exists.
For example, "administrator" or "bureaucrat"
| string | $group | Internal group name |
| string | UserIdentity | $member |
Definition at line 2932 of file Language.php.
| MediaWiki\Language\Language::getGroupName | ( | $group | ) |
Gets the localized friendly name for a group, if it exists.
For example, "Administrators" or "Bureaucrats"
| string | $group | Internal group name |
Definition at line 2918 of file Language.php.
|
protected |
Get a HookContainer, for hook metadata and running extension hooks.
Definition at line 4991 of file Language.php.
|
protected |
Get a HookRunner, for running core hooks.
Definition at line 5003 of file Language.php.
Referenced by MediaWiki\Language\Language\getNamespaces().
| MediaWiki\Language\Language::getHtmlCode | ( | ) |
Get the code in BCP 47 format which we can use inside html lang="" tags.
NOTE: The return value of this function is NOT HTML-safe and must be escaped with htmlspecialchars() or similar.
Definition at line 4535 of file Language.php.
Referenced by MediaWiki\ResourceLoader\DateFormatterConfig\getDataForLang().
| MediaWiki\Language\Language::getHumanTimestamp | ( | MWTimestamp | $time, |
| ?MWTimestamp | $relativeTo = null, | ||
| ?UserIdentity | $user = null ) |
Get the timestamp in a human-friendly relative format, e.g., "3 days ago".
Determine the difference between the timestamp and the current time, and generate a readable timestamp by returning "<N> <units> ago", where the largest possible unit is used.
| MWTimestamp | $time | |
| MWTimestamp | null | $relativeTo | The base timestamp to compare to (defaults to now) |
| UserIdentity | null | $user | User the timestamp is being generated for (or null to use main context's user) |
Definition at line 2803 of file Language.php.
References MediaWiki\Utils\MWTimestamp\offsetForUser().
Referenced by MediaWiki\Api\ApiBlockInfoHelper\getBlockDetails().
| MediaWiki\Language\Language::getJsData | ( | ) |
Definition at line 5012 of file Language.php.
| MediaWiki\Language\Language::getJsDateFormats | ( | ) |
Definition at line 5031 of file Language.php.
Referenced by MediaWiki\ResourceLoader\DateFormatterConfig\getDataForLang().
| MediaWiki\Language\Language::getLocalNsIndex | ( | $text | ) |
Get a namespace key by case-insensitive value.
Only matches namespace names for the current language, not the canonical ones defined in Namespace.php.
| string | $text |
Definition at line 547 of file Language.php.
References MediaWiki\Language\Language\getNamespaceIds(), and MediaWiki\Language\Language\lc().
| MediaWiki\Language\Language::getMagic | ( | $mw | ) |
Fill a MagicWord object with data from this instance.
| MagicWord | $mw |
Definition at line 3484 of file Language.php.
References wfWarn().
| MediaWiki\Language\Language::getMagicWords | ( | ) |
Get all the magic words from the localisation cache.
Definition at line 3475 of file Language.php.
| MediaWiki\Language\Language::getMessage | ( | $key | ) |
| string | $key |
Reimplemented in MediaWiki\Languages\LanguageQqx.
Definition at line 2945 of file Language.php.
| MediaWiki\Language\Language::getMessageFromDB | ( | $msg | ) |
Get a message from the MediaWiki namespace.
| string | $msg | Message name |
Definition at line 711 of file Language.php.
| MediaWiki\Language\Language::getMonthAbbreviation | ( | $key | ) |
| int | $key | Number from 1 to 12 |
Definition at line 759 of file Language.php.
Referenced by MediaWiki\Parser\DateFormatter\__construct(), and MediaWiki\ResourceLoader\DateFormatterConfig\getDataForLang().
| MediaWiki\Language\Language::getMonthAbbreviationsArray | ( | ) |
Definition at line 766 of file Language.php.
| MediaWiki\Language\Language::getMonthName | ( | $key | ) |
| int | $key | Number from 1 to 12 |
Definition at line 732 of file Language.php.
Referenced by MediaWiki\Parser\DateFormatter\__construct(), MediaWiki\Languages\LanguageWa\date(), and MediaWiki\ResourceLoader\DateFormatterConfig\getDataForLang().
| MediaWiki\Language\Language::getMonthNameGen | ( | $key | ) |
| int | $key | Number from 1 to 12 |
Definition at line 751 of file Language.php.
Referenced by MediaWiki\ResourceLoader\DateFormatterConfig\getDataForLang().
| MediaWiki\Language\Language::getMonthNamesArray | ( | ) |
Definition at line 739 of file Language.php.
| MediaWiki\Language\Language::getNamespaceAliases | ( | ) |
Definition at line 557 of file Language.php.
References MediaWiki\Language\Language\$namespaceAliases, MediaWiki\MainConfigNames\ExtraGenderNamespaces, MediaWiki\Language\Language\getConverterInternal(), MediaWiki\Language\Language\getNamespaces(), MediaWiki\MainConfigNames\NamespaceAliases, and NS_PROJECT_TALK.
Referenced by MediaWiki\Language\Language\getNamespaceIds().
| MediaWiki\Language\Language::getNamespaceIds | ( | ) |
Definition at line 615 of file Language.php.
References MediaWiki\Language\Language\$mNamespaceIds, MediaWiki\Language\Language\getNamespaceAliases(), MediaWiki\Language\Language\getNamespaces(), and MediaWiki\Language\Language\lc().
Referenced by MediaWiki\Language\Language\getLocalNsIndex(), and MediaWiki\Language\Language\getNsIndex().
| MediaWiki\Language\Language::getNamespaces | ( | ) |
Returns an array of localised namespaces (with underscores, without considering language variants) indexed by their numbers.
If the namespace is not available in localised form, it will be included in English.
Definition at line 388 of file Language.php.
References MediaWiki\Language\Language\$namespaceNames, MediaWiki\MainConfigNames\ExtraNamespaces, MediaWiki\Language\Language\getHookRunner(), MediaWiki\MainConfigNames\MetaNamespace, MediaWiki\MainConfigNames\MetaNamespaceTalk, NS_PROJECT, and NS_PROJECT_TALK.
Referenced by MediaWiki\Language\Language\getFormattedNamespaces(), MediaWiki\Language\Language\getNamespaceAliases(), MediaWiki\Language\Language\getNamespaceIds(), and MediaWiki\Language\Language\getNsText().
| MediaWiki\Language\Language::getNsIndex | ( | $text | ) |
Get a namespace key by case-insensitive value.
Canonical namespace names override custom ones defined for the current language.
| string | $text |
Definition at line 639 of file Language.php.
References MediaWiki\Language\Language\getNamespaceIds(), and MediaWiki\Language\Language\lc().
| MediaWiki\Language\Language::getNsText | ( | $index | ) |
Get a namespace value by key.
Namespace name uses underscores (not spaces), e.g. 'MediaWiki_talk'.
$mw_ns = $lang->getNsText( NS_MEDIAWIKI_TALK ); echo $mw_ns; // prints 'MediaWiki_talk'
| int | $index | The array key of the namespace to return |
Definition at line 476 of file Language.php.
References MediaWiki\Language\Language\getNamespaces().
Referenced by MediaWiki\Language\Language\getFormattedNsText(), and MediaWiki\Language\Language\getGenderNsText().
| MediaWiki\Language\Language::getPluralRuleIndexNumber | ( | $number | ) |
Find the index number of the plural rule appropriate for the given number.
| int | $number |
Definition at line 4955 of file Language.php.
| MediaWiki\Language\Language::getPluralRules | ( | ) |
Get the plural rules for the language.
Definition at line 4911 of file Language.php.
| MediaWiki\Language\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'.
| int | $number |
Definition at line 4969 of file Language.php.
| MediaWiki\Language\Language::getPluralRuleTypes | ( | ) |
Get the plural rule types for the language.
Definition at line 4933 of file Language.php.
|
protected |
Specify the language variant that should be used for search indexing.
Reimplemented in MediaWiki\Languages\LanguageGan, MediaWiki\Languages\LanguageWuu, and MediaWiki\Languages\LanguageZh.
Definition at line 3198 of file Language.php.
| MediaWiki\Language\Language::getSpecialPageAliases | ( | ) |
Get special page names, as an associative array canonical name => array of valid names, including aliases.
Definition at line 3501 of file Language.php.
| MediaWiki\Language\Language::getVariantname | ( | $code, | |
| $usemsg = true ) |
Short names for language variants used for language conversion links.
| string | $code | |
| bool | $usemsg | Use the "variantname-xyz" message if it exists |
Definition at line 656 of file Language.php.
References MediaWiki\Language\Language\msg().
| MediaWiki\Language\Language::getWeekdayAbbreviation | ( | $key | ) |
| MediaWiki\Language\Language::getWeekdayName | ( | $key | ) |
|
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 the string value is returned. Otherwise the array is returned for further consideration by CLDR rules or overridden convertPlural().
| int | $count | Non-localized number |
| string[] | $forms | Different plural forms |
Definition at line 4306 of file Language.php.
Referenced by MediaWiki\Languages\LanguageKsh\convertPlural().
| MediaWiki\Language\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.
Reimplemented in MediaWiki\Languages\LanguageYue, and MediaWiki\Languages\LanguageZh_hans.
Definition at line 3178 of file Language.php.
|
static |
Hebrew Gematria number formatting up to 9999.
| int | $num |
Definition at line 1911 of file Language.php.
| MediaWiki\Language\Language::iconv | ( | $in, | |
| $out, | |||
| $string ) |
| string | $in | |
| string | $out | |
| string | $string |
Definition at line 2963 of file Language.php.
|
staticprotected |
| string | $string | |
| string | $pattern |
Definition at line 3243 of file Language.php.
Referenced by MediaWiki\Languages\LanguageJa\segmentByWord(), MediaWiki\Languages\LanguageYue\segmentByWord(), and MediaWiki\Languages\LanguageZh_hans\segmentByWord().
| MediaWiki\Language\Language::isRTL | ( | ) |
| MediaWiki\Language\Language::isSameCodeAs | ( | Bcp47Code | $other | ) |
Compare this Language object to a Bcp47Code.
This is part of the Bcp47Code interface.
| Bcp47Code | $other |
Definition at line 4558 of file Language.php.
Referenced by MediaWiki\Message\Message\inLanguage().
| MediaWiki\Language\Language::lc | ( | $str, | |
| $first = false ) |
| string | $str | |
| bool | $first | Whether to lowercase only the first character |
Definition at line 3057 of file Language.php.
Referenced by MediaWiki\Language\Language\getLocalNsIndex(), MediaWiki\Language\Language\getNamespaceIds(), and MediaWiki\Language\Language\getNsIndex().
| MediaWiki\Language\Language::lcfirst | ( | $str | ) |
| string | $str |
Reimplemented in MediaWiki\Languages\LanguageKaa, and MediaWiki\Languages\LanguageTr.
Definition at line 3029 of file Language.php.
| MediaWiki\Language\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]].
Definition at line 4500 of file Language.php.
| MediaWiki\Language\Language::linkPrefixExtension | ( | ) |
To allow "foo[[bar]]" to extend the link over the whole word "foobar".
Definition at line 3466 of file Language.php.
| MediaWiki\Language\Language::linkTrail | ( | ) |
A regular expression to match legal word-trailing characters which should be merged onto a link of the form [[foo]]bar.
Definition at line 4490 of file Language.php.
| MediaWiki\Language\Language::listToText | ( | array | $list | ) |
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".
| string[] | $list |
Definition at line 3755 of file Language.php.
Referenced by MediaWiki\Message\Message\listTypeMap().
| MediaWiki\Language\Language::minimumGroupingDigits | ( | ) |
The minimum number of digits a number must have, in addition to the grouping size, before grouping separators are added.
For example, Polish has minimumGroupingDigits = 2, which with a grouping size of 3 causes 4-digit numbers to be written like 9999, but 5-digit numbers are written like "10 000".
Definition at line 3742 of file Language.php.
|
protected |
Gets the Message object from this language.
Only for use inside this class.
| string | $msg | Message name |
| MessageParam|MessageSpecifier|string|int|float|list<MessageParam|MessageSpecifier|string|int|float> | ...$params See Message::params() |
Definition at line 724 of file Language.php.
Referenced by MediaWiki\Language\Language\getVariantname().
| MediaWiki\Language\Language::needsGenderDistinction | ( | ) |
Whether this language uses gender-dependent namespace aliases.
See https://www.mediawiki.org/wiki/Manual:$wgExtraGenderNamespaces
Definition at line 522 of file Language.php.
References MediaWiki\MainConfigNames\ExtraGenderNamespaces, MediaWiki\MainConfigNames\ExtraNamespaces, NS_USER, and NS_USER_TALK.
Referenced by MediaWiki\Page\SitemapGenerator\__construct().
| MediaWiki\Language\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.
| string | $s |
Reimplemented in MediaWiki\Languages\LanguageAr, and MediaWiki\Languages\LanguageMl.
Definition at line 3315 of file Language.php.
| MediaWiki\Language\Language::normalizeForSearch | ( | $text | ) |
Some languages have special punctuation need to be normalized.
Make such changes here.
Some languages such as Chinese have many-to-one conversions, e.g., it should be better to use zh-hans for search, since conversion from zh-hant to zh-hans is less ambiguous than the other way around.
| string | $text |
Reimplemented in MediaWiki\Languages\LanguageZh_hans, and MediaWiki\Languages\LanguageBe_tarask.
Definition at line 3213 of file Language.php.
| MediaWiki\Language\Language::parseFormattedNumber | ( | $number | ) |
| MediaWiki\Language\Language::pipeList | ( | array | $list | ) |
Same as commaList, but separate it with the pipe instead.
| string[] | $list | Array of strings to put in a pipe list |
Definition at line 3808 of file Language.php.
Referenced by MediaWiki\Message\Message\listTypeMap().
|
protected |
Checks that convertPlural was given an array and pads it to requested number of forms by copying the last one.
| array | $forms | |
| int | $count | Minimum number of forms |
Definition at line 4327 of file Language.php.
Referenced by MediaWiki\Languages\LanguageKsh\convertPlural().
|
protected |
Remove bytes that represent an incomplete Unicode character at the end of string (e.g.
bytes of the char are missing)
| string | $string |
Definition at line 3939 of file Language.php.
| MediaWiki\Language\Language::resetNamespaces | ( | ) |
Resets all the namespace caches.
Mainly used for testing
Definition at line 440 of file Language.php.
|
static |
Roman number formatting up to 10000.
| int | $num |
Definition at line 1880 of file Language.php.
| MediaWiki\Language\Language::segmentByWord | ( | $string | ) |
Some languages such as Chinese require word segmentation, Specify such segmentation when overridden in derived class.
| string | $string |
Reimplemented in MediaWiki\Languages\LanguageJa, MediaWiki\Languages\LanguageYue, and MediaWiki\Languages\LanguageZh_hans.
Definition at line 3189 of file Language.php.
| MediaWiki\Language\Language::segmentForDiff | ( | $text | ) |
Languages like Chinese need to be segmented in order for the diff to be of any use.
| string | $text |
Reimplemented in MediaWiki\Languages\LanguageZh.
Definition at line 4470 of file Language.php.
| MediaWiki\Language\Language::semicolonList | ( | array | $list | ) |
Take a list of strings and build a locale-friendly semicolon-separated list, using the local semicolon-separator message.
| string[] | $list | Array of strings to put in a semicolon list |
Definition at line 3795 of file Language.php.
Referenced by MediaWiki\Message\Message\listTypeMap().
| MediaWiki\Language\Language::separatorTransformTable | ( | ) |
Definition at line 3730 of file Language.php.
| MediaWiki\Language\Language::setNamespaces | ( | array | $namespaces | ) |
Arbitrarily set all the namespace names at once.
Mainly used for testing
| string[] | $namespaces | Array of namespaces (id => name) |
Definition at line 431 of file Language.php.
| MediaWiki\Language\Language::specialList | ( | $page, | |
| $details ) |
Make a list item, used by various special pages.
| string | $page | Page link |
| string | $details | HTML safe text between brackets |
Definition at line 4827 of file Language.php.
| MediaWiki\Language\Language::sprintfDate | ( | $format, | |
| $ts, | |||
| ?DateTimeZone | $zone = null, | ||
| & | $ttl = 'unused' ) |
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 xit t (days in month) in Iranian calendar xiz z (day of the 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.
| string | $format | |
| string | $ts | 14-character timestamp YYYYMMDDHHMMSS 01234567890123 |
| DateTimeZone | null | $zone | Timezone of $ts |
| int | null | &$ttl | The amount of time (in seconds) the output may be cached for. Only makes sense if $ts is the current time. |
Definition at line 889 of file Language.php.
| MediaWiki\Language\Language::time | ( | $ts, | |
| $adj = false, | |||
| $format = true, | |||
| $timecorrection = false ) |
| string | $ts | The time format which needs to be turned into a date('YmdHis') format with wfTimestamp(TS::MW,$ts) |
| bool | $adj | Whether to adjust the time output according to the user configured offset ($timecorrection) |
| mixed | $format | True to use user's date format preference |
| string | false | $timecorrection | The time offset as returned by validateTimeZone() in Special:Preferences |
Definition at line 2504 of file Language.php.
References wfTimestamp().
Referenced by MediaWiki\Languages\LanguageWa\timeanddate().
| MediaWiki\Language\Language::timeanddate | ( | $ts, | |
| $adj = false, | |||
| $format = true, | |||
| $timecorrection = false ) |
| string | $ts | The time format which needs to be turned into a date('YmdHis') format with wfTimestamp(TS::MW,$ts) |
| bool | $adj | Whether to adjust the time output according to the user configured offset ($timecorrection) |
| mixed | $format | What date format to return the result in; if it's false output the default one (default true) |
| string | false | $timecorrection | The time offset as returned by validateTimeZone() in Special:Preferences |
Reimplemented in MediaWiki\Languages\LanguageWa.
Definition at line 2524 of file Language.php.
References wfTimestamp().
| MediaWiki\Language\Language::toBcp47Code | ( | ) |
Implement the Bcp47Code interface.
This is an alias for ::getHtmlCode().
Definition at line 4547 of file Language.php.
|
protected |
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.
| string | $dataClass | Name of a normalized pairs' data class |
| string | $input |
Definition at line 3339 of file Language.php.
Referenced by MediaWiki\Languages\LanguageAr\normalize(), and MediaWiki\Languages\LanguageMl\normalize().
| MediaWiki\Language\Language::translateBlockExpiry | ( | $str, | |
| ?UserIdentity | $user = null, | ||
| $now = 0 ) |
| string | $str | The validated block duration in English |
| UserIdentity | null | $user | User to use timezone from or null for the context user |
| int | $now | Current timestamp, for formatting relative block durations |
Reimplemented in MediaWiki\Languages\LanguageFi.
Definition at line 4421 of file Language.php.
References wfIsInfinity().
| MediaWiki\Language\Language::truncateForDatabase | ( | $string, | |
| $length, | |||
| $ellipsis = '...', | |||
| $adjustLength = true ) |
Truncate a string to a specified length in bytes, appending an optional string (e.g., for ellipsis) When an ellipsis isn't needed, using mb_strcut() directly is recommended.
If $length is negative, the string will be truncated from the beginning
| string | $string | String to truncate |
| int | $length | Maximum length in bytes |
| string | $ellipsis | String to append to the end of truncated text |
| bool | $adjustLength | Subtract length of ellipsis from $length |
Definition at line 3831 of file Language.php.
| MediaWiki\Language\Language::truncateForVisual | ( | $string, | |
| $length, | |||
| $ellipsis = '...', | |||
| $adjustLength = true ) |
Truncate a string to a specified number of characters, appending an optional string (e.g., for ellipsis).
This provides the multibyte version of truncateForDatabase() method of this class, suitable for truncation based on number of characters, instead of number of bytes.
The input should be a raw UTF-8 string, and NOT be HTML escaped. It is not safe to truncate HTML-escaped strings, because the entity can be truncated! Use ::truncateHtml() if you need a specific number of HTML-encoded bytes, or ::truncateForDatabase() if you need a specific number of PHP bytes.
If $length is negative, the string will be truncated from the beginning.
| string | $string | String to truncate |
| int | $length | Maximum number of characters |
| string | $ellipsis | String to append to the end of truncated text |
| bool | $adjustLength | Subtract length of ellipsis from $length |
Definition at line 3862 of file Language.php.
Referenced by MediaWiki\Gallery\TraditionalImageGallery\getCaptionHtml(), and MediaWiki\ChangeTags\ChangeTags\getChangeTagList().
| MediaWiki\Language\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 , where 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.
| string | $text | HTML string to truncate |
| int | $length | (zero/positive) Maximum HTML length (including ellipses) |
| string | $ellipsis | String to append to the truncated text |
Definition at line 3973 of file Language.php.
| MediaWiki\Language\Language::uc | ( | $str, | |
| $first = false ) |
| string | $str | |
| bool | $first | Whether to uppercase only the first character |
Definition at line 3017 of file Language.php.
| MediaWiki\Language\Language::ucfirst | ( | $str | ) |
| string | $str |
Reimplemented in MediaWiki\Languages\LanguageAz, MediaWiki\Languages\LanguageKaa, and MediaWiki\Languages\LanguageTr.
Definition at line 2978 of file Language.php.
| MediaWiki\Language\Language::ucwordbreaks | ( | $str | ) |
capitalize words at word breaks
| string | $str |
Definition at line 3103 of file Language.php.
References $matches.
| MediaWiki\Language\Language::ucwords | ( | $str | ) |
| string | $str |
Definition at line 3077 of file Language.php.
References $matches.
| MediaWiki\Language\Language::unsegmentForDiff | ( | $text | ) |
And unsegment to show the result.
| string | $text |
Reimplemented in MediaWiki\Languages\LanguageZh.
Definition at line 4480 of file Language.php.
| MediaWiki\Language\Language::userAdjust | ( | $ts, | |
| $tz = false ) |
Used by date() and time() to adjust the time output.
| string | $ts | The time in date('YmdHis') format |
| string | false | $tz | Adjust the time by this amount (default false, mean we get user timecorrection setting) |
Definition at line 1997 of file Language.php.
Referenced by MediaWiki\Languages\LanguageWa\date().
| MediaWiki\Language\Language::userDate | ( | $ts, | |
| UserIdentity | $user, | ||
| array | $options = [] ) |
Get the formatted date for the given timestamp and formatted for the given user.
| mixed | $ts | Mixed: the time format which needs to be turned into a date('YmdHis') format with wfTimestamp(TS::MW,$ts) |
| UserIdentity | $user | User used to get preferences for timezone and format |
| array | $options | Array, can contain the following keys:
|
Definition at line 2738 of file Language.php.
Referenced by MediaWiki\Skin\Components\SkinComponentLastModified\getTemplateData().
| MediaWiki\Language\Language::userTime | ( | $ts, | |
| UserIdentity | $user, | ||
| array | $options = [] ) |
Get the formatted time for the given timestamp and formatted for the given user.
| mixed | $ts | The time format which needs to be turned into a date('YmdHis') format with wfTimestamp(TS::MW,$ts) |
| UserIdentity | $user | User used to get preferences for timezone and format |
| array | $options | Array, can contain the following keys:
|
Definition at line 2761 of file Language.php.
Referenced by MediaWiki\Skin\Components\SkinComponentLastModified\getTemplateData(), and MediaWiki\RecentChanges\ChangesList\revDateLink().
| MediaWiki\Language\Language::userTimeAndDate | ( | $ts, | |
| UserIdentity | $user, | ||
| array | $options = [] ) |
Get the formatted date and time for the given timestamp and formatted for the given user.
| mixed | $ts | The time format which needs to be turned into a date('YmdHis') format with wfTimestamp(TS::MW,$ts) |
| UserIdentity | $user | User used to get preferences for timezone and format |
| array | $options | Array, can contain the following keys:
|
Definition at line 2784 of file Language.php.
Referenced by MediaWiki\RecentChanges\ChangesList\revDateLink().
| string [][] MediaWiki\Language\Language::$dateFormatStrings = [] |
|
static |
Definition at line 290 of file Language.php.
| string MediaWiki\Language\Language::$mCode |
Definition at line 73 of file Language.php.
| string [][] null MediaWiki\Language\Language::$mExtendedSpecialPageAliases |
| MediaWiki\Language\Language::$mMagicExtensions = [] |
Definition at line 78 of file Language.php.
|
static |
Definition at line 224 of file Language.php.
|
static |
Definition at line 202 of file Language.php.
|
protected |
Indexed by localized lower-cased namespace name.
Definition at line 100 of file Language.php.
Referenced by MediaWiki\Language\Language\getNamespaceIds().
|
protected |
Map from alias to namespace ID.
Definition at line 102 of file Language.php.
Referenced by MediaWiki\Language\Language\getNamespaceAliases().
|
protected |
Indexed by numeric namespace ID.
Definition at line 98 of file Language.php.
Referenced by MediaWiki\Language\Language\getNamespaces().
|
protected |
Definition at line 271 of file Language.php.
| const MediaWiki\Language\Language::HEBREW_CALENDAR_MONTH_GENITIVE_MESSAGES |
Definition at line 250 of file Language.php.
| const MediaWiki\Language\Language::HEBREW_CALENDAR_MONTHS_MESSAGES |
Definition at line 239 of file Language.php.
| const MediaWiki\Language\Language::HIJRI_CALENDAR_MONTH_MESSAGES |
Definition at line 261 of file Language.php.
| const MediaWiki\Language\Language::IRANIAN_CALENDAR_MONTHS_MESSAGES |
Definition at line 229 of file Language.php.
| const MediaWiki\Language\Language::MONTH_ABBREVIATED_MESSAGES |
Definition at line 216 of file Language.php.
| const MediaWiki\Language\Language::MONTH_GENITIVE_MESSAGES |
Definition at line 207 of file Language.php.
| const MediaWiki\Language\Language::MONTH_MESSAGES |
Definition at line 193 of file Language.php.
| const MediaWiki\Language\Language::WEEKDAY_ABBREVIATED_MESSAGES |
Definition at line 186 of file Language.php.
| const MediaWiki\Language\Language::WEEKDAY_MESSAGES |
Definition at line 178 of file Language.php.