[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/languages/classes/ -> LanguageBe_tarask.php (source)

   1  <?php
   2  /**
   3   * Belarusian in Taraškievica orthography (Беларуская тарашкевіца) specific code.
   4   *
   5   * This program is free software; you can redistribute it and/or modify
   6   * it under the terms of the GNU General Public License as published by
   7   * the Free Software Foundation; either version 2 of the License, or
   8   * (at your option) any later version.
   9   *
  10   * This program is distributed in the hope that it will be useful,
  11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13   * GNU General Public License for more details.
  14   *
  15   * You should have received a copy of the GNU General Public License along
  16   * with this program; if not, write to the Free Software Foundation, Inc.,
  17   * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18   * http://www.gnu.org/copyleft/gpl.html
  19   *
  20   * @file
  21   * @author Ævar Arnfjörð Bjarmason <[email protected]>
  22   * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
  23   * @license http://www.gnu.org/copyleft/fdl.html GNU Free Documentation License
  24   * @ingroup Language
  25   */
  26  
  27  /**
  28   * Belarusian in Taraškievica orthography (Беларуская тарашкевіца)
  29   *
  30   * @ingroup Language
  31   * @see http://be-x-old.wikipedia.org/wiki/Project_talk:LanguageBe_tarask.php
  32   */
  33  // @codingStandardsIgnoreStart Ignore class name is not in camel caps format error
  34  class LanguageBe_tarask extends Language {
  35      // @codingStandardsIgnoreEnd
  36      /**
  37       * The Belarusian language uses apostrophe sign,
  38       * but the characters used for this could be both U+0027 and U+2019.
  39       * This function unifies apostrophe sign in search index values
  40       * to enable seach using both apostrophe signs.
  41       *
  42       * @param string $string
  43       *
  44       * @return string
  45       */
  46  	function normalizeForSearch( $string ) {
  47          wfProfileIn( __METHOD__ );
  48  
  49          # MySQL fulltext index doesn't grok utf-8, so we
  50          # need to fold cases and convert to hex
  51  
  52          # Replacing apostrophe sign U+2019 with U+0027
  53          $s = preg_replace( '/\xe2\x80\x99/', '\'', $string );
  54  
  55          $s = parent::normalizeForSearch( $s );
  56  
  57          wfProfileOut( __METHOD__ );
  58          return $s;
  59      }
  60  
  61      /**
  62       * Four-digit number should be without group commas (spaces)
  63       * So "1 234 567", "12 345" but "1234"
  64       *
  65       * @param string $_
  66       *
  67       * @return string
  68       */
  69  	function commafy( $_ ) {
  70          if ( preg_match( '/^-?\d{1,4}(\.\d*)?$/', $_ ) ) {
  71              return $_;
  72          } else {
  73              return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );
  74          }
  75      }
  76  }


Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1