*/
function getVariantname( $code, $usemsg = true ) {
$msg = "variantname-$code";
- list( $rootCode ) = explode( '-', $code );
if ( $usemsg && wfMessage( $msg )->exists() ) {
return $this->getMessageFromDB( $msg );
}
return $this->sprintfDate( $df, $ts );
}
- /**
- * Takes a number of seconds and turns it into a text using values such as hours and minutes.
- *
- * @since 1.20
- *
- * @param integer $seconds The amount of seconds.
- * @param array $chosenIntervals The intervals to enable.
- *
- * @return string
- */
- public function formatDuration( $seconds, array $chosenIntervals = array( 'millennia', 'centuries', 'decades', 'years', 'days', 'hours', 'minutes', 'seconds' ) ) {
- $intervals = array(
- 'millennia' => 1000 * 31557600,
- 'centuries' => 100 * 31557600,
- 'decades' => 10 * 31557600,
- 'years' => 31557600, // 86400 * 365.25
- 'weeks' => 604800,
- 'days' => 86400,
- 'hours' => 3600,
- 'minutes' => 60,
- 'seconds' => 1,
- );
-
- if ( !empty( $chosenIntervals ) ) {
- $intervals = array_intersect_key( $intervals, array_flip( $chosenIntervals ) );
- }
-
- $segments = array();
-
- foreach ( $intervals as $name => $length ) {
- $value = floor( $seconds / $length );
-
- if ( $value > 0 || ( $name == 'seconds' && empty( $segments ) ) ) {
- $seconds -= $value * $length;
- $message = new Message( 'duration-' . $name, array( $value ) );
- $segments[] = $message->inLanguage( $this )->escaped();
- }
- }
-
- return $this->listToText( $segments );
- }
-
/**
* Internal helper function for userDate(), userTime() and userTimeAndDate()
*
}
/**
- * A hidden direction mark (LRM or RLM), depending on the language direction
+ * 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.
+ *
+ * @param $opposite Boolean Get the direction mark opposite to your language
+ * @return string
+ */
+ function getDirMarkEntity( $opposite = false ) {
+ if ( $opposite ) { return $this->isRTL() ? '‎' : '‏'; }
+ return $this->isRTL() ? '‏' : '‎';
+ }
+
+ /**
+ * 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.
*
* @param $opposite Boolean Get the direction mark opposite to your language
* @return string
*/
function getDirMark( $opposite = false ) {
- $rtl = "\xE2\x80\x8F";
- $ltr = "\xE2\x80\x8E";
- if ( $opposite ) { return $this->isRTL() ? $ltr : $rtl; }
- return $this->isRTL() ? $rtl : $ltr;
+ $lrm = "\xE2\x80\x8E"; # LEFT-TO-RIGHT MARK, commonly abbreviated LRM
+ $rlm = "\xE2\x80\x8F"; # RIGHT-TO-LEFT MARK, commonly abbreviated RLM
+ if ( $opposite ) { return $this->isRTL() ? $lrm : $rlm; }
+ return $this->isRTL() ? $rlm : $lrm;
}
/**
}
return $word;
}
-
+ /**
+ * Get the grammar forms for the content language
+ * @return array of grammar forms
+ * @since 1.20
+ */
+ function getGrammarForms() {
+ global $wgGrammarForms;
+ if ( isset( $wgGrammarForms[$this->getCode()] ) && is_array( $wgGrammarForms[$this->getCode()] ) ) {
+ return $wgGrammarForms[$this->getCode()];
+ }
+ return array();
+ }
/**
* Provides an alternative text depending on specified gender.
* Usage {{gender:username|masculine|feminine|neutral}}.
/**
* Decode an expiry (block, protection, etc) which has come from the DB
- *
+ *
* @FIXME: why are we returnings DBMS-dependent strings???
*
* @param $expiry String: Database expiry String