BlueSpice MediaWiki master
|
Static Public Member Functions | |
static | factory ($code) |
static | isSupportedLanguage ($code) |
static | isWellFormedLanguageTag ($code, $lenient=false) |
static | isValidCode ($code) |
static | isValidBuiltInCode ($code) |
static | isKnownLanguageTag ($tag) |
static | getLocalisationCache () |
static | fetchLanguageNames ($inLanguage=null, $include= 'mw') |
static | fetchLanguageName ($code, $inLanguage=null, $include= 'all') |
static | romanNumeral ($num) |
static | hebrewNumeral ($num) |
static | getCodeFromFileName ($filename, $prefix= 'Language', $suffix= '.php') |
static | classFromCode ($code, $fallback=true) |
static | getFileName ($prefix= 'Language', $code, $suffix= '.php') |
static | getMessagesFileName ($code) |
static | getJsonMessagesFileName ($code) |
static | getFallbackFor ($code) |
static | getFallbacksFor ($code) |
static | getFallbacksIncludingSiteLanguage ($code) |
static | getMessagesFor ($code) |
static | getMessageFor ($key, $code) |
static | getMessageKeysFor ($code) |
Public Attributes | |
$mConverter | |
$mVariants | |
$mCode | |
$mLoaded = false | |
$mMagicExtensions = [] | |
$mMagicHookDone = false | |
$mParentLanguage = false | |
$dateFormatStrings = [] | |
$mExtendedSpecialPageAliases | |
$namespaceAliases | |
$transformData = [] | |
Protected Member Functions | |
msg ($msg) | |
doMagicHook () | |
removeBadCharLast ($string) | |
removeBadCharFirst ($string) | |
handleExplicitPluralForms ($count, array $forms) | |
preConvertPlural ($forms, $count) | |
Static Protected Member Functions | |
static | newFromCode ($code, $fallback=false) |
static | convertDoubleWidth ($string) |
static | insertSpace ($string, $pattern) |
Protected Attributes | |
$namespaceNames | |
$mNamespaceIds | |
Internationalisation code
Language::__destruct | ( | ) |
Reduce memory usage
Language::addMagicWordsByLang | ( | $newWords | ) |
Add magic words to the extension array
array | $newWords |
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....
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....
Language::autoConvert | ( | $text, | |
$variant = false |
|||
) |
convert text to a variant
string | $text | text to convert |
string | bool | $variant | variant to convert to, or false to use the user's preferred variant (if logged in), or the project default variant |
Language::autoConvertToAllVariants | ( | $text | ) |
convert text to all supported variants
string | $text |
Language::capitalizeAllNouns | ( | ) |
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 |
Language::checkTitleEncoding | ( | $s | ) |
|
static |
string | $code | |
bool | $fallback | Whether we're going through language fallback chain |
Language::commafy | ( | $number | ) |
Adds commas to a given number
mixed | $number |
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 |
Language::convert | ( | $text | ) |
convert text to different variants of a language.
string | $text |
Language::convertCategoryKey | ( | $key | ) |
string | $key |
|
staticprotected |
convert double-width roman characters to single-width. range: ff00-ff5f ~= 0020-007f
string | $string |
Language::convertForSearchResult | ( | $termsArray | ) |
array | $termsArray |
Language::convertGrammar | ( | $word, | |
$case | |||
) |
Grammatical transformations, needed for inflected languages Invoked by putting {{grammar:case|word}} in a message
string | $word | |
string | $case |
Language::convertHtml | ( | $text, | |
$isTitle = false |
|||
) |
Perform output conversion on a string, and encode for safe HTML output.
string | $text | Text to be converted |
bool | $isTitle | Whether this conversion is for the article title |
Language::convertNamespace | ( | $ns, | |
$variant = null |
|||
) |
Convert a namespace index to a string in the preferred variant
int | $ns | namespace index (https://www.mediawiki.org/wiki/Manual:Namespace) |
string | null | $variant | variant to convert to, or null to use the user's preferred variant (if logged in), or the project default variant |
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}}
int | $count | Non-localized number |
array | $forms | Different plural forms |
Language::convertTitle | ( | $title | ) |
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 | bool | $timecorrection | The time offset as returned by validateTimeZone() in Special:Preferences |
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. |
Language::digitGroupingPattern | ( | ) |
Language::digitTransformTable | ( | ) |
|
protected |
Run the LanguageGetMagic hook once.
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.
string | $text | Text to wrap |
Language::emphasize | ( | $text | ) |
Italic is unsuitable for some languages
string | $text | The text to be emphasized. |
Language::equals | ( | Language | $lang | ) |
|
static |
Get a cached or new language object for a given language code
string | $code |
MWException |
Language::fallback8bitEncoding | ( | ) |
|
static |
string | $code | The code of the language for which to get the name |
null | string | $inLanguage | Code of language in which to return the name (null for autonyms) |
string | $include | 'all', 'mw' or 'mwfile'; see fetchLanguageNames() |
|
static |
Get an array of language names, indexed by code.
null | string | $inLanguage | Code of language in which to return the names Use null for autonyms (native names) |
string | $include | One of: '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 |
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 The input parameters may be modified upon return
string | &$link | The name of the link |
Title | &$nt | The title object of the link |
bool | $ignoreOtherCond | To disable other conditions when we need to transclude a template or update a category's link |
Language::firstChar | ( | $s | ) |
Get the first character of a string.
string | $s |
Language::fixVariableInNamespace | ( | $talk | ) |
string | $talk |
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().
int | $bps |
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 uesd |
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 amount of seconds. |
array | $chosenIntervals | The intervals to enable. |
Language::formatExpiry | ( | $expiry, | |
$format = true , |
|||
$infinity = 'infinity' |
|||
) |
Decode an expiry (block, protection, etc) which has come from the DB
string | $expiry | Database expiry String |
bool | int | $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 |
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 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.
int | float | $number | The string to be formatted, should be an integer or a floating point number. |
bool | $nocommafy | Set to true for special numbers like dates |
Language::formatNumNoSeparators | ( | $number | ) |
Front-end for non-commafied formatNum
int | float | $number | The string to be formatted, should be an integer or a floating point number. |
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()
int | $size | Size to format |
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'] === '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. |
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.
string | $gender | |
array | $forms |
Language::getAllMessages | ( | ) |
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. |
Language::getBookstoreList | ( | ) |
Exports $wgBookstoreListEn
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
|
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 |
Language::getCompiledPluralRules | ( | ) |
Get the compiled plural rules for the language
Language::getConverter | ( | ) |
Language::getConvRuleTitle | ( | ) |
Get the conversion rule title, if any.
Language::getDateFormats | ( | ) |
Language::getDateFormatString | ( | $type, | |
$pref | |||
) |
Get a format string for a given type and preference
string | $type | May be 'date', 'time', 'both', or 'pretty'. |
string | $pref | The format name as it appears in Messages*.php under $datePreferences. |
Language::getDatePreferenceMigrationMap | ( | ) |
Language::getDatePreferences | ( | ) |
Language::getDefaultDateFormat | ( | ) |
Language::getDefaultVariant | ( | ) |
Language::getDir | ( | ) |
Return the correct HTML 'dir' attribute value for this 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. When the output is HTML, use getDirMarkEntity() instead.
bool | $opposite | Get the direction mark opposite to your 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.
bool | $opposite | Get the direction mark opposite to your 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 amount of seconds. |
array | $chosenIntervals | The intervals to enable. |
Language::getExtraHashOptions | ( | ) |
returns language specific options used by User::getPageRenderHash() for example, the preferred language variant
Language::getExtraUserToggles | ( | ) |
|
static |
Get the first fallback for a given language.
string | $code |
Language::getFallbackLanguages | ( | ) |
|
static |
Get the ordered list of fallback languages.
string | $code | Language code |
|
static |
Get the ordered list of fallback languages, ending with the fallback language chain for the site language.
string | $code | Language code |
|
static |
Get the name of a file for a certain language code
string | $prefix | Prepend this to the filename |
string | $code | Language code |
string | $suffix | Append this to the filename |
MWException |
Language::getFormattedNamespaces | ( | ) |
A convenience function that returns getNamespaces() with spaces instead of underscores in values. Useful for producing output to be displayed e.g. in <select>
forms.
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'
int | $index | The array key of the namespace to return |
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... ) |
Language::getGrammarForms | ( | ) |
Get the grammar forms for the content 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.
MWException |
Language::getHebrewCalendarMonthName | ( | $key | ) |
string | $key |
Language::getHebrewCalendarMonthNameGen | ( | $key | ) |
string | $key |
Language::getHijriCalendarMonthName | ( | $key | ) |
string | $key |
Language::getHtmlCode | ( | ) |
Get the code in BCP 47 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.
Language::getHumanTimestamp | ( | MWTimestamp | $time, |
MWTimestamp | $relativeTo = null , |
||
User | $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) |
User | null | $user | User the timestamp is being generated for (or null to use main context's user) |
Language::getImageFile | ( | $image | ) |
string | $image |
Language::getImageFiles | ( | ) |
Language::getIranianCalendarMonthName | ( | $key | ) |
string | $key |
|
static |
|
static |
Get the LocalisationCache instance
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.
string | $text |
Language::getMagicWords | ( | ) |
Get all magic words from cache.
Language::getMessage | ( | $key | ) |
string | $key |
|
static |
Get a message for a given language
string | $key | |
string | $code |
Language::getMessageFromDB | ( | $msg | ) |
|
static |
Get all message keys for a given language. This is a faster alternative to array_keys( Language::getMessagesFor( $code ) )
string | $code | Language code |
|
static |
string | $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().
string | $code |
Language::getMonthAbbreviation | ( | $key | ) |
string | $key |
Language::getMonthAbbreviationsArray | ( | ) |
Language::getMonthName | ( | $key | ) |
string | $key |
Language::getMonthNameGen | ( | $key | ) |
string | $key |
Language::getMonthNamesArray | ( | ) |
Language::getNamespaceAliases | ( | ) |
Language::getNamespaceIds | ( | ) |
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.
Language::getNsIndex | ( | $text | ) |
Get a namespace key by value, case insensitive. Canonical namespace names override custom ones defined for the current language.
string | $text |
Language::getNsText | ( | $index | ) |
Get a namespace value by key
$mw_ns = $wgContLang->getNsText( NS_MEDIAWIKI ); echo $mw_ns; // prints 'MediaWiki'
int | $index | The array key of the namespace to return |
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).
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.
Language::getPluralRuleIndexNumber | ( | $number | ) |
Find the index number of the plural rule appropriate for the given number
int | $number |
Language::getPluralRules | ( | ) |
Get the plural rules for the 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 |
Language::getPluralRuleTypes | ( | ) |
Get the plural rule types for the language
Language::getPreferredVariant | ( | ) |
Language::getSpecialPageAliases | ( | ) |
Get special page names, as an associative array canonical name => array of valid names, including aliases
Language::getURLVariant | ( | ) |
Language::getUserToggle | ( | $tog | ) |
string | $tog |
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 |
Language::getVariants | ( | ) |
Get the list of variants supported by this language see sample implementation in LanguageZh.php
Language::getWeekdayAbbreviation | ( | $key | ) |
string | $key |
Language::getWeekdayName | ( | $key | ) |
string | $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 string value returned, otherwise array returned for further consideration by CLDR rules or overridden convertPlural().
int | $count | Non-localized number |
array | $forms | Different plural forms |
Language::hasVariant | ( | $variant | ) |
Check if the language has the specific variant
string | $variant |
Language::hasVariants | ( | ) |
Check if this is a language with variants
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.
|
static |
Hebrew Gematria number formatting up to 9999
int | $num |
Language::iconv | ( | $in, | |
$out, | |||
$string | |||
) |
string | $in | |
string | $out | |
string | $string |
Language::initContLang | ( | ) |
Hook which will be called if this is the content language. Descendants can use this to register hook functions or modify globals
Language::initEncoding | ( | ) |
|
staticprotected |
string | $string | |
string | $pattern |
|
static |
Returns true if a language code is an IETF tag known to MediaWiki.
string | $tag |
Language::isMultibyte | ( | $str | ) |
string | $str |
Language::isRTL | ( | ) |
For right-to-left language support
|
static |
|
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.
string | $code |
MWException |
|
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.
string | $code |
|
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
string | $code | |
bool | $lenient | Whether to allow '_' as separator. The default is only '-'. |
Language::lc | ( | $str, | |
$first = false |
|||
) |
string | $str | |
bool | $first |
Language::lcfirst | ( | $str | ) |
string | $str |
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]].
Language::linkPrefixExtension | ( | ) |
To allow "foo[[bar]]" to extend the link over the whole word "foobar"
Language::linkTrail | ( | ) |
A regular expression to match legal word-trailing characters which should be merged onto a link of the form [[foo]]bar.
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…)
string[] | $l |
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.
string | $text | Text to be used for external link |
bool | $noParse | Wrap it without confirming it's a real URL first |
Language::minimumGroupingDigits | ( | ) |
|
protected |
Language::needsGenderDistinction | ( | ) |
Whether this language uses gender-dependent namespace aliases. See https://www.mediawiki.org/wiki/Manual:$wgExtraGenderNamespaces
|
staticprotected |
Create a language object for a given language code
string | $code | |
bool | $fallback | Whether we're going through language fallback chain |
MWException |
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.
string | $s |
Language::normalizeForSearch | ( | $string | ) |
Some languages have special punctuation need to be normalized. Make such changes here.
string | $string |
Language::parseFormattedNumber | ( | $number | ) |
string | $number |
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 |
|
protected |
Checks that convertPlural was given an array and pads it to requested amount of forms by copying the last one.
array | $forms | Array of forms given to convertPlural |
int | $count | How many forms should there be at least |
Language::recodeForEdit | ( | $s | ) |
Language::recodeInput | ( | $s | ) |
|
protected |
Remove bytes that represent an incomplete Unicode character at the start of string (e.g. bytes of the char are missing)
string | $string |
|
protected |
Remove bytes that represent an incomplete Unicode character at the end of string (e.g. bytes of the char are missing)
string | $string |
Language::replaceGrammarInNamespace | ( | $m | ) |
string | $m |
Language::resetNamespaces | ( | ) |
Resets all of the namespace caches. Mainly used for testing
|
static |
Roman number formatting up to 10000
int | $num |
Language::segmentByWord | ( | $string | ) |
Some languages such as Chinese require word segmentation, Specify such segmentation when overridden in derived class.
string | $string |
Language::segmentForDiff | ( | $text | ) |
languages like Chinese need to be segmented in order for the diff to be of any use
string | $text |
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 |
Language::separatorTransformTable | ( | ) |
Language::setCode | ( | $code | ) |
string | $code |
Language::setNamespaces | ( | array | $namespaces | ) |
Arbitrarily set all of the namespace names at once. Mainly used for testing
array | $namespaces | Array of namespaces (id => name) |
Language::specialList | ( | $page, | |
$details, | |||
$oppositedm = true |
|||
) |
Make a list item, used by various special pages
string | $page | Page link |
string | $details | HTML safe text between brackets |
bool | $oppositedm | Add the direction mark opposite to your language, to display text properly |
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 | $zone | Timezone of $ts |
int | &$ttl | The amount of time (in seconds) the output may be cached for. Only makes sense if $ts is the current time. |
MWException |
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 | bool | $timecorrection | The time offset as returned by validateTimeZone() in Special:Preferences |
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 format to return, if it's false output the default one (default true) |
string | bool | $timecorrection | The time offset as returned by validateTimeZone() in Special:Preferences |
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.
string | $file | |
string | $string |
MWException |
Language::translateBlockExpiry | ( | $str, | |
User | $user = null , |
||
$now = 0 |
|||
) |
string | $str | The validated block duration in English |
User | $user | User object to use timezone from or null for $wgUser |
int | $now | Current timestamp, for formatting relative block durations |
Language::truncate | ( | $string, | |
$length, | |||
$ellipsis = '...' , |
|||
$adjustLength = true |
|||
) |
This method is deprecated since 1.31 and kept as alias for truncateForDatabase, which has replaced it. This method provides truncation suitable for DB.
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.
string | $string | String to truncate |
int | $length | Maximum length (including ellipsis) |
string | $ellipsis | String to append to the truncated text |
bool | $adjustLength | Subtract length of ellipsis from $length. $adjustLength was introduced in 1.18, before that behaved as if false. |
Language::truncateForDatabase | ( | $string, | |
$length, | |||
$ellipsis = '...' , |
|||
$adjustLength = true |
|||
) |
Truncate a string to a specified length in bytes, appending an optional string (e.g. for ellipsis)
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 |
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 multibyte version of truncate() method of this class, suitable for truncation based on number of characters, instead of number of 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 |
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.
string | $text | HTML string to truncate |
int | $length | (zero/positive) Maximum length (including ellipses) |
string | $ellipsis | String to append to the truncated text |
Language::uc | ( | $str, | |
$first = false |
|||
) |
Convert a string to uppercase
string | $str | |
bool | $first |
Language::ucfirst | ( | $str | ) |
Make a string's first character uppercase
string | $str |
Language::ucwordbreaks | ( | $str | ) |
capitalize words at word breaks
string | $str |
Language::ucwordbreaksCallbackAscii | ( | $matches | ) |
array | $matches |
Language::ucwordbreaksCallbackMB | ( | $matches | ) |
array | $matches |
Language::ucwords | ( | $str | ) |
string | $str |
Language::ucwordsCallbackMB | ( | $matches | ) |
array | $matches |
Language::unsegmentForDiff | ( | $text | ) |
and unsegment to show the result
string | $text |
Language::updateConversionTable | ( | Title | $title | ) |
Language::userAdjust | ( | $ts, | |
$tz = false |
|||
) |
Language::userDate | ( | $ts, | |
User | $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) |
User | $user | User object used to get preferences for timezone and format |
array | $options | Array, can contain the following keys:
|
Language::userTime | ( | $ts, | |
User | $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) |
User | $user | User object used to get preferences for timezone and format |
array | $options | Array, can contain the following keys:
|
Language::userTimeAndDate | ( | $ts, | |
User | $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) |
User | $user | User object used to get preferences for timezone and format |
array | $options | Array, can contain the following keys:
|
Language::viewPrevNext | ( | Title | $title, |
$offset, | |||
$limit, | |||
array | $query = [] , |
||
$atend = false |
|||
) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Language::$transformData = [] |
ReplacementArray object caches